Skip to content

fix: isolate named client scopes and mixed registration collisions - #203

Merged
Tony133 merged 2 commits into
fastify:mainfrom
melroy89:fix/named-registration-scopes
Oct 15, 2026
Merged

Tony133 merged 2 commits into
fastify:mainfrom
melroy89:fix/named-registration-scopes

Conversation

@melroy89

@melroy89 melroy89 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #201. That PR fixed names inherited from Object.prototype when creating a fresh named registry. Two additional combinations still fail: child registrations mutate an inherited parent registry, and registering __proto__ after an unnamed client changes its prototype and bypasses duplicate detection.

Create a local registry when a child adds a named client, retaining inherited clients while isolating parent and sibling scopes. Define named clients as own data properties, including when an unnamed client already exists. Independent siblings can reuse names; collisions with inherited names and actual client properties still fail.

These fixes were developed in my MariaDB fork in melroy89/fastify-mariadb#4, which also addresses startup cleanup. This PR ports only the registration fixes and their regression coverage to the mysql2-based plugin.

Validation with mysql2 3.24.4, Node.js 24, and isolated MySQL 9.7.2:

  • npm run lint and all 15 TypeScript assertions passed.
  • 55 runtime tests passed with 100% statement, branch, function, and line coverage.
  • The original local registration reproduction script now confirms scope isolation, independent sibling names, and safe duplicate detection after an unnamed registration. The script remains outside the repository.

@Tony133 Tony133 changed the title Fix named client scope isolation and mixed registration collisions fix: isolate named client scopes and mixed registration collisions Oct 15, 2026
@Tony133
Tony133 merged commit 04bbbb8 into fastify:main Oct 15, 2026
8 checks passed
@melroy89
melroy89 deleted the fix/named-registration-scopes branch October 15, 2026 12:45
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