Skip to content

Fix named instances with built-in object property names - #201

Merged
Tony133 merged 2 commits into
fastify:mainfrom
melroy89:fix/named-instance-property-collisions
Oct 9, 2026
Merged

Tony133 merged 2 commits into
fastify:mainfrom
melroy89:fix/named-instance-property-collisions

Conversation

@melroy89

Copy link
Copy Markdown
Contributor

Summary

Named instances currently use a plain object and check fastify.mysql[name] for duplicates. Names inherited from Object.prototype, such as toString and constructor, are therefore rejected even when unused; __proto__ also needs a dictionary without a prototype to work as a key.

Use a null-prototype dictionary and check only own properties. Add a regression test for all three names.

I found and fixed the same issue in my MariaDB fork: melroy89/fastify-mariadb#3

Verification

  • npm run lint
  • npm run test:typescript
  • npm run test:unit against isolated MySQL 9.7.2: 43 passed, 100% coverage

@Tony133
Tony133 merged commit ed011de into fastify:main Oct 9, 2026
8 checks passed
@melroy89
melroy89 deleted the fix/named-instance-property-collisions branch October 9, 2026 18:51
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