Skip to content

fix(compartment-mapper): remove unused type from ModuleSourceHookModuleSource#3115

Merged
boneskull merged 1 commit intomasterfrom
boneskull/more-module-source-hook-tests
Mar 5, 2026
Merged

fix(compartment-mapper): remove unused type from ModuleSourceHookModuleSource#3115
boneskull merged 1 commit intomasterfrom
boneskull/more-module-source-hook-tests

Conversation

@boneskull
Copy link
Member

@boneskull boneskull commented Mar 5, 2026

  • Removes unused ModuleSourceHook's "error" module source type.
  • Adds tests for specific behavior around exit modules
  • Fix a JSDoc import

@boneskull
Copy link
Member Author

📚 Pull Request Stack


Managed by gh-stack

@changeset-bot
Copy link

changeset-bot bot commented Mar 5, 2026

🦋 Changeset detected

Latest commit: 1cd1246

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@endo/compartment-mapper Patch
@endo/bundle-source Patch
@endo/check-bundle Patch
@endo/cli Patch
@endo/daemon Patch
@endo/import-bundle Patch
@endo/test262-runner Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@boneskull boneskull requested a review from naugtur March 5, 2026 01:01
@boneskull boneskull self-assigned this Mar 5, 2026
reexports?: string[] | undefined;
sha512?: string | undefined;
}
| { error: string }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error seems to be missing. Is that deliberate?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the unused one. AFAIR, it represents a deferred error and it is not being exposed via the hook (because it's not actually a module but an explicit representation of a lack of one in case someone attempts to require it)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(yes, it is deliberate)

exit: moduleSpecifier,
},
canonicalName: compartmentDescriptor.label,
canonicalName: moduleSpecifier,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is correct.

My understanding of what the facts are (please correct me if I'm wrong)

  • this is only reachable for exit modules
  • endo has a less specific meaning for exit modules - they're modules that were not provided in compartment map. In lavamoat they should be limited to node builtins and native modules
  • the compartmentDescriptor here is the parent compartment in which the exit module was requested
  • moduleSpecifier happens to be compatible with canonicalName but formally is not one

With that, I'd rather have canonicalName be undefined for exit modules or remain the parent label, so that values passed to the hook as canonicalName always have a matching compartment.

Copy link
Member Author

@boneskull boneskull Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had considered undefined but this breaks the API in a way I didn't want to deal with.

FWIW, if canonicalName is the "parent" canonicalName (i.e. I revert this change), then we're just right back where we started (sans type changes). I am fine with that.

@boneskull boneskull force-pushed the boneskull/more-module-source-hook-tests branch from abe2c9b to eba230b Compare March 5, 2026 23:09
@boneskull boneskull changed the title fix(compartment-mapper): moduleSourceHook uses specifier for exit module's canonicalName fix(compartment-mapper): remove unused type from ModuleSourceHookModuleSource Mar 5, 2026
…leSource

- Removes unused `ModuleSourceHook`'s "error" module source type.
- Adds tests for specific behavior around exit modules
- Fix a JSDoc import
@boneskull boneskull force-pushed the boneskull/more-module-source-hook-tests branch from eba230b to 1cd1246 Compare March 5, 2026 23:52
@boneskull boneskull enabled auto-merge March 5, 2026 23:53
@boneskull boneskull merged commit 8cccb75 into master Mar 5, 2026
21 checks passed
@boneskull boneskull deleted the boneskull/more-module-source-hook-tests branch March 5, 2026 23:59
@github-actions github-actions bot mentioned this pull request Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants