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

Context is undefined in singleton services #4

Open
unlight opened this issue Jan 21, 2021 · 1 comment
Open

Context is undefined in singleton services #4

unlight opened this issue Jan 21, 2021 · 1 comment

Comments

@unlight
Copy link

unlight commented Jan 21, 2021

I'm doing how it is described in readme. However, it does not work for services which created on application start. Only for scoped services, like controllers, graphql resolvers.

Is it possible to get it worked for singleton services?

@pylebecq
Copy link

pylebecq commented Sep 1, 2022

At least the typing needs to be fixed. RequestContext::get() method return type should be T | undefined as the docs says that getStore() can return undefined.

If called outside of an asynchronous context initialized by calling asyncLocalStorage.run() or asyncLocalStorage.enterWith(), it returns undefined.

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

No branches or pull requests

2 participants