Skip to content

test(ses): Verify namespace mutation parity with Node.js#3231

Open
kriskowal wants to merge 1 commit into
masterfrom
kriskowal-namespace-mutation
Open

test(ses): Verify namespace mutation parity with Node.js#3231
kriskowal wants to merge 1 commit into
masterfrom
kriskowal-namespace-mutation

Conversation

@kriskowal

Copy link
Copy Markdown
Member

Add a test that compares Node.js native ESM and a SES Compartment when one module does import * as foo from './a'; foo.x = 'bar' and another module later imports x from the same module.

Both runtimes prevent the override (assignment throws TypeError, later imports see the original value), but the protection mechanism differs in observable ways: Node.js exposes data descriptors with writable: true on a non-frozen, non-extensible namespace, while SES exposes accessor descriptors on a frozen target. The test pins down both the parity behaviors and the structural differences.
These differences are known discrepancies the authors have found no way to emulate faithfully.

The fixture is loaded once from disk and fed to both runtimes (Node.js via subprocess, the Compartment via @endo/module-source) so the two sides cannot drift.

@changeset-bot

changeset-bot Bot commented May 1, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d704b3c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@kriskowal kriskowal force-pushed the kriskowal-namespace-mutation branch from 2848fad to bace5d8 Compare May 1, 2026 21:05
@kriskowal kriskowal force-pushed the kriskowal-namespace-mutation branch from bace5d8 to c6a779d Compare May 21, 2026 06:29
kriscendobot pushed a commit to endojs/endo-but-for-bots that referenced this pull request May 21, 2026
Upstream endo's `yarn build:types:check` and typedoc-driven pass run TS
with `useUnknownInCatchVariables: true`, which types the `catch (e)`
binding as `unknown` and rejects bare `e.name`. The mirror's CI passes
because its `lint:types` runs `tsc` against the package tsconfig only,
which inherits a looser baseline; the upstream lint job (per
endojs/endo#3231) flagged b.js:23:28 with TS18046.

Apply the project's documented convention from CLAUDE.md (Cast catch
error variables: /** @type {Error} */ (e).name) so the fixture compiles
under both the mirror's relaxed tsconfig and upstream's stricter
pipeline.

Reproduced locally by extending packages/ses/tsconfig.json with
`useUnknownInCatchVariables: true` and running `tsc`: before the cast
the only namespace-mutation error is the exact upstream report
(b.js(23,28) TS18046); after the cast the error is gone and
`yarn lint` and the `namespace-mutation` test both pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kriscendobot

Copy link
Copy Markdown

Mirror of endojs/endo-but-for-bots#79 (head c6a779d).

kriskowal pushed a commit to kriskowal/garden that referenced this pull request Jun 7, 2026
@kriskowal kriskowal force-pushed the kriskowal-namespace-mutation branch from c6a779d to d704b3c Compare June 7, 2026 05:48
kriskowal pushed a commit to kriskowal/garden that referenced this pull request Jun 7, 2026
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.

2 participants