Skip to content

fix(npm): correct package_store_prefix_len for links in external-repo sub-packages#2896

Open
ma-oli wants to merge 1 commit into
aspect-build:mainfrom
ma-oli:fix-package_store_prefix_len-with-external
Open

fix(npm): correct package_store_prefix_len for links in external-repo sub-packages#2896
ma-oli wants to merge 1 commit into
aspect-build:mainfrom
ma-oli:fix-package_store_prefix_len-with-external

Conversation

@ma-oli

@ma-oli ma-oli commented Jun 25, 2026

Copy link
Copy Markdown

_symlink_package_store strips package_store_prefix_len characters from a dependency's package_store_directory.short_path to form the relative symlink target. The length omitted the "/" separators that follow the package path and the repo name, so for a link target in a non-root package of an external repository it stripped two characters too few. The leftover was the trailing "s/" of ".aspect_rules_js/", producing dangling symlinks such as ../../s/<pkg>@<ver>/node_modules/<pkg> and ERR_MODULE_NOT_FOUND at runtime.

In a root module the miscount is only one character and is masked by "//" path collapsing, so it surfaces only when a module's npm packages live in a sub-package (e.g. //frontend) and that module is consumed as an external dependency.

Account for both separators: +1 after the package path and +1 after the repo name.


Changes are visible to end-users: yes/no

  • Searched for relevant documentation and updated as needed: yes/no
  • Breaking change (forces users to change their own code or config): yes/no
  • Suggested release notes appear below: yes/no

Test plan

  • Covered by existing test cases
  • New test cases added
  • Manual testing; please provide instructions so we can reproduce:

… sub-packages

`_symlink_package_store` strips `package_store_prefix_len` characters from a
dependency's `package_store_directory.short_path` to form the relative symlink
target. The length omitted the "/" separators that follow the package path and
the repo name, so for a link target in a non-root package of an external
repository it stripped two characters too few. The leftover was the trailing
"s/" of ".aspect_rules_js/", producing dangling symlinks such as
`../../s/<pkg>@<ver>/node_modules/<pkg>` and `ERR_MODULE_NOT_FOUND` at runtime.

In a root module the miscount is only one character and is masked by "//" path
collapsing, so it surfaces only when a module's npm packages live in a
sub-package (e.g. //frontend) and that module is consumed as an external
dependency.

Account for both separators: +1 after the package path and +1 after the repo
name.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@jbedard

jbedard commented Jun 25, 2026

Copy link
Copy Markdown
Member

Can you add a test reproducing the issue? I would think such an error would have been caught by now so there must be something unique going on here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants