Skip to content
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

Merged
merged 2 commits into from
Nov 28, 2020
Merged

fix: close cache on server close #41

merged 2 commits into from
Nov 28, 2020

Conversation

simoneb
Copy link
Member

@simoneb simoneb commented Nov 27, 2020

Fixes #40

For sanity, do this when reviewing the code changes:

image

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,
Copy link
Member Author

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())
Copy link
Member Author

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

Copy link
Member Author

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)
Copy link
Member Author

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

@simoneb
Copy link
Member Author

simoneb commented Nov 28, 2020

@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.

Copy link
Contributor

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@simoneb simoneb merged commit 716b655 into master Nov 28, 2020
@simoneb simoneb deleted the fix/close-cache branch November 28, 2020 17:49
@simoneb simoneb mentioned this pull request Dec 1, 2020
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.

Open handle prevents Jest from exiting
2 participants