8000 Keep extension packers distinct for same-name constructors by Aschenbath · Pull Request #167 · kawanet/msgpack-lite · GitHub
[go: up one dir, main page]

Skip to content

Keep extension packers distinct for same-name constructors - #167

Open
Aschenbath wants to merge 2 commits into
kawanet:mainfrom
Aschenbath:fix/oss20more-20261124-bc63-msgpack-constructor-collision
Open

Aschenbath wants to merge 2 commits into
kawanet:mainfrom
Aschenbath:fix/oss20more-20261124-bc63-msgpack-constructor-collision

Conversation

@Aschenbath
@Aschenbath Aschenbath commented Nov 24, 2026 •
Copy link
Copy Markdown
Contributor

Registering two independent constructors named Message currently causes instances of the first to be encoded with the second constructor's extension type. Re-registering either constructor also changes the other, and a custom constructor named Date can replace the preset Date encoder.

Retain constructor identity for the named fast path and preserve displaced packers in the existing identity fallback list. Registered constructors with the same name then keep their own packers, while the name fallback remains available for values from another realm. Unique preset constructors stay on the fast path and do not populate the linear fallback list.

The regression cases run against both the source entry point and the tracked minified bundle. They cover name collisions, repeated registration, preset collisions, and unnamed/Object fallback constructors in both Node and the browser suite. Separate Node tests preserve cross-realm Date and typed-array compatibility. The six collision cases fail against unchanged upstream.

Validation on Node 24.22.0:

  • JSHint and node --test test/*.js: all 215 tests pass.
  • The browser suite passes all 199 tests in headless Chromium using the Makefile's Rollup and runner configuration, including both sets of constructor-collision regressions.
  • Browserify/Uglify use the Makefile's exact options. Rebuilding the unchanged source first reproduced the tracked bundle byte-for-byte; the fixed bundle is 50,117 bytes, below the 60,000-byte cap.
  • Silent import passes with pending deprecations enabled. Browser-global and CommonJS bundle exports pass smoke checks; the browser-global bundle also round-trips both same-name constructors.

Prepared with Codex assistance; reproduced, reviewed, and validated locally.

This branch has not been deployed

No deployments
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.

1 participant

0