Replies: 4 comments 4 replies
-
|
cc @domenic ping |
Beta Was this translation helpful? Give feedback.
-
|
I think I've finally found the most concise way to demonstrate this with no other dependencies And I want to re-iterate that I don't think this is necessarily a problem with jsdom, but that this problem with the global dispatcher could probably pop up in other scenarios as well. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks @KarlGe for the very helpful reproduction case. Claude's analysis seems pretty accurate here:
Possible fixes:
It's also possible that after #4785 is merged, jsdom can stop using Thoughts welcome. |
Beta Was this translation helpful? Give feedback.
-
|
@domenic can you create a reproduction for what jsdom is using? undici v7 was theoretically designed to avoid this kind of problem, but it seems we have missed a case. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello! Trying to step carefully here because it's a bit hard to narrow this down.
We're running into a problem with using JSDOM
through Vitest, and in the end I think this needs to be solved in Vitest, probably.I'm on Node: 22.13.1
Using jsdom: 28.0.0
which depends on undici: 7.20.0
The error I was originally getting is
But it might still be relevant here, the problem happens in the unwrap-handler
https://github.com/nodejs/undici/blob/main/lib/handler/unwrap-handler.js#L90
So it's using the node:internal version of undici (6.21.0 in Node 22.13.1), which seemed weird to me.
I think probably what is happening is that Vitest overrides the global fetch to use Node's version, which then triggerssetGlobalDispatcherhere https://github.com/nodejs/undici/blob/main/lib/global.js#L5 so then when jsdom tries using a global dispatcher from a newer version of undici, it gets the one that's already definedSo again, we'll figure out exactly how to solve this for our case (upgrading Node works just fine), but I'm wondering if this means that the globalDispatcher symbol name should be updated so that it's more resilient to version mismatches like this?
Update: See repro below, in our case it's probably Axios that makes this happen, not Vitest, but it can be reproduced by just using fetch before importing JSDOM
Beta Was this translation helpful? Give feedback.
All reactions