fix: support frozen globalThis - #72
Merged
ronag merged 1 commit intoAug 30, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens Undici’s global dispatcher and live-socket registry publishing logic to work correctly when globalThis is frozen, and adds regression tests to cover freezing both before and after import.
Changes:
- Add a module-local fallback dispatcher in
lib/global.jssosetGlobalDispatcher()/getGlobalDispatcher()continue to work whenglobalThiscannot be mutated. - Make the socket registry resilient to non-extensible/frozen globals by avoiding
??=publication to aSymbol.forslot when the global cannot accept new properties, while keeping the legacy alias behavior when possible. - Add isolated child-process tests covering both “freeze before import” and “freeze after import” scenarios, including dispatcher identity and socket tracking/removal.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/global-frozen.js | Runs a fixture in two freeze phases to validate frozen-global behavior in isolated processes. |
| test/fixtures/frozen-global.js | Exercises dispatcher replacement semantics and socket registry behavior under a frozen globalThis. |
| lib/global.js | Introduces a fallback dispatcher path when defining the global symbol property fails due to a frozen/non-extensible global. |
| lib/core/socket-registry.js | Avoids publishing new global symbol/alias properties when globalThis is non-extensible, while preserving cross-copy sharing when already published. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ronag
marked this pull request as ready for review
August 29, 2026 20:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
globalThisis frozensetGlobalDispatcher()/getGlobalDispatcher()replacement semantics when the freeze happens either before import or after the initial dispatcher is publishedUpstream fix: nodejs#5574
Validation
Exact head:
286f1dabc3a5020fdcc276e3381e449731ebb66fon Node.js v26.7.0npm test: unit 576 passed, 6 skipped; node-test 151 passed; type tests passednpm run lintgit diff --check