-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat!: v1 #1
feat!: v1 #1
Conversation
index.js
Outdated
|
||
module.exports = fp( | ||
function fastifyRacePlugin (fastify, globalOpts, next) { | ||
const controllers = new Map() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks very leak-prone. Maybe use a WeakMap instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about that at the first iteration, but I wasn't sure under which circumstances the onResponse
cannot be called so the Map is not cleaned properly. But I think for avoiding unexpected issues would be better to go with a WeakMap as you suggested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, here is what do you recommend to use the key for the WeakMap? My initial thought is to take advantage of the request, as is ready to be gc'ed once the request is done. wdyt?
Hi @mcollina please have a look, I refactored the implementation to use WeakMaps instead, thanks for the feedback 🙂 |
Merging now, please feel free to provide more feedback afterwards 🙂 |
Pending