Closed kibertoad closed 3 years ago
@puzpuzpuz Maybe you have any ideas what could be wrong? Wasn't https://github.com/nodejs/node/pull/36394 supposed to be a non-breaking change?
I would recommend opening this on Node.js
@Qard can you take a look?
I'll try to find some time to look at it soon. Just got vaccinated yesterday so I'm a bit out of commission today. 😷
Looks like probably the same issue as was discovered in DataDog/dd-trace-js#1095, which seems to be only producible when running in Node.js 16.2.0 and jest. I'll try to find some time to copy/paste the tests into vanilla scripts without jest possibly tomorrow to verify.
Got a bit of time to try it before bed and as I thought, it only happens within Jest. So Jest must be doing something different. Not sure what. 🤔
@puzpuzpuz Maybe you have any ideas what could be wrong? Wasn't nodejs/node#36394 supposed to be a non-breaking change?
Yes, it supposed to be a non-breaking change. And I can also see test failures in https://github.com/puzpuzpuz/cls-rtracer + node v16.2.0 which uses jest.
The short term fix is to migrate off Jest. It's a good thing to do anyway.
(Jest does an absurd amount of monkeypatching of core, so any internal change is likely to break them).
@mcollina Yes, I'm thinking about rewriting tests in TAP. The only concern that I have is that Jest is a very popular framework, and if fastify-request-context
will start failing for people using it again in the future, and we don't have a quick way to repro it, that will be inconvenient. So I wonder if we should have also tests in Jest, that will be ignored for now.
@puzpuzpuz Gotcha, thank you for the clarification!
I posted a reproduction of the issue that doesn't use Jest here: https://github.com/nodejs/node/pull/38577#issuecomment-846536583
It looks like a fix should land in Node 16.3.0.
Confirmed, 16.3.0 resolves the issue.
Prerequisites
Fastify version
3.x.x
Node.js version
16.2.0
Operating system
Windows
Operating system version (i.e. 20.04, 11.3, 10)
Linux, Windows, doesn't matter
Description
All tests are failing when being run on Node 16.2.0. Seems like all stored values are lost and are being resolved to
undefined
.Considering that tests for https://github.com/kibertoad/asynchronous-local-storage are still passing with 16.2.0, looks like this particular plugin is doing something wrong.
Steps to Reproduce
Execute existing test suite on Node 16.2.0
Expected Behavior
Test suite passes.