-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: close cache on server close #41
Conversation
This is inserted to make this compatible with prettier. | ||
Once https://github.com/prettier/prettier/issues/3845 and https://github.com/prettier/prettier/issues/3847 are solved this might be not needed any more. | ||
*/ | ||
'space-before-function-paren': 0, |
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.
no point in fighting, let there be spaces
) | ||
instance.decorateRequest('auth0VerifySecretsCache', cache) | ||
|
||
instance.addHook('onClose', () => cache.close()) |
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 is the actual fix
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 must admit that I'm not actually sure that this fixes the issue, because based on the stack trace this is not where the issue is happening, but inside the got package instead. Weird though, because got is not supposed to be using any cache by default, so I'm not even sure why that code it being hit.
Finally, we are using Jest for the plugin's tests too but it's not hanging there.
@PatrickHeneise are you sure that you're not using got directly in your code and using the cache? That may explain it, though I guess you are not doing that.
In any case, this is a good fix even if it doesn't address the issue directly,
@PatrickHeneise can you try this out before we publish a new version?
@@ -98,9 +96,9 @@ const tokens = { | |||
async function buildServer(options) { | |||
const server = fastify() | |||
|
|||
server.register(fastifyAuth0, options) | |||
server.register(require('.'), options) |
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.
requiring the plugin each time so it can be mocked
@ShogunPanda I switched to node-fetch in order to address this issue which is likely due to using got. I realized that it was done in #5 to address a concern around timeout, but it's not true that node-fetch doesn't support timeouts, it does in fact and I set it to 5 seconds in this PR. |
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.
lgtm
Fixes #40
For sanity, do this when reviewing the code changes: