Comments (8)
It seems like an issue with the Node version I was using. See this:
With Node 16.14:
jlongo@x:~/git/test$ nvm use 16.14
Now using node v16.14.2 (npm v8.5.0)
jlongo@x:~/git/test$ ./node_modules/.bin/jest --detectOpenHandles
PASS ./test.js
GET `/` route
✓ test (73 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.325 s, estimated 1 s
Ran all test suites.
With Node 16.3.2:
jlongo@x:~/git/test$ nvm use 16.13.2
Now using node v16.13.2 (npm v8.1.2)
jlongo@x:~/git/test$ ./node_modules/.bin/jest --detectOpenHandles
PASS ./test.js
GET `/` route
✓ test (71 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.331 s, estimated 1 s
Ran all test suites.
Jest has detected the following 1 open handle potentially keeping Jest from exiting:
● fastify-request-context
34 |
35 | it('test', (done) => {
> 36 | fastify.inject({
| ^
37 | method: 'GET',
38 | url: '/'
39 | }, (err, response) => {
at Object.ready (node_modules/fastify/fastify.js:481:13)
at Object.inject (node_modules/fastify/fastify.js:459:12)
at Object.<anonymous> (test.js:36:13)
at TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:333:13)
at runJest (node_modules/@jest/core/build/runJest.js:404:19)
at _run10000 (node_modules/@jest/core/build/cli/index.js:320:7)
at runCLI (node_modules/@jest/core/build/cli/index.js:173:3)
Thanks!
from fastify-request-context.
Does this happen without Jest?
from fastify-request-context.
This is a limitation of Jest.
from fastify-request-context.
This is not a limitation of Jest. Jest has a nice feature that checks if we are not closing properly the resources at the end of the tests. Without 'fastify-request-context', there is no issue. Essentially, Jest is telling us there are pending resources with 'fastify-request-context', even after we call fastify.close()
.
I'm not sure if other libraries have this check.
from fastify-request-context.
That's how the request context work. There is likely something that has becomes part of your promise chain. It's likely safe.
from fastify-request-context.
This library actually tested with jest
. If it has problem with open handles
, the test should be failed.
I have follow your repro and it is actually no error on my end.
$ node -v
v16.14.0
$ jest --detectOpenHandles
PASS ./test.js
GET `/` route
✓ test (698 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 2.815 s
Ran all test suites.
Done in 6.83s.
Your error actually pointing to fastify.js#L481 which means something is not handled properly inside the onReady
hook when process exit.
Do you have any onReady
hook registered for the instance
?
from fastify-request-context.
Note that I enabled the option "--detectOpenHandles". The test won't fail if there are open handles, but it's a warning the code is not closing all resources properly.
@climba03003 no, the scenario I sent just contains those files.
Is there a way I can force "fastify-request-context" to close?
from fastify-request-context.
Note that I enabled the option "--detectOpenHandles". The test won't fail if there are open handles, but it's a warning the code is not closing all resources properly.
@climba03003 no, the scenario I sent just contains those files.
Is there a way I can force "fastify-request-context" to close?
You can see my command is running jest --detectOpenHandles
and it works very well. The time is long because I am running benchmark job in background.
from fastify-request-context.
Related Issues (17)
- Default value persists if used wrongly HOT 3
- Expose API for direct access to the context HOT 5
- Allow set the defaultStoreValues by factory HOT 3
- Please publish version 3.1.1 to npm HOT 4
- ALS is deprecated and archived, Better to use AsyncLocalStorage class fom the async_hook std module HOT 12
- lost context when use @fastify/multipart HOT 8
- Enable default context items derived from `request`
- Stricter default context interface? HOT 4
- Customizable AsyncResource.type and create-resource HOT 2
- CI seems to be failing HOT 4
- Update files HOT 1
- FastifyDeprecation: You are decorating Request/Reply with a reference type HOT 3
- Node 16.2.0 with Jest break AsyncLocalStorage HOT 13
- [FSTDEP006] FastifyDeprecation: You are decorating Request/Reply with a reference type. This reference is shared amongst all requests. Use onRequest hook instead. HOT 1
- Plugin not working with fastify 3.x HOT 1
- Using `strict` in a project `tsconfig.json` makes `requestContext.get(string)` possibly `undefined` HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastify-request-context.