sorry for all the spam, haha
sorry for all the spam, haha
that error is not really actionable 😦
28 Replies
No worries! Thanks for being an early adopter! 😅 Could you paste your output with
NODE_DEBUG=vitest-pool-workers:module-fallback
again?gotcha, looks like another package that's not esm ready
Are you using
pg
by chance?no
we're using planetscale + drizzle
Ah ok 👍
do you think there's a way to make this work with cjs modules?
cause that seems to be a pretty large blocker for us at least
I could probalby spend a few more hours patching modules manually, but at some point it becomes hard to reproduce 😄
You could try force those deps to be "inlined": https://vitest.dev/config/#server-deps-inline. This will force them to be transformed by Vite first, rather than loading them as is.
Something like
test: { server: { deps: { inline: [/@hono\/zod-validator/] } } }
tried that for a bit, after adding a few, I've arrived at a new error 😄
I'm guessing it's still trying to import some cjs
Interesting, that error suggests something is trying to import
createRequire()
from the node:module
module. Does it give a stack trace?
not really
tried with your debug flag as well but couldn't find anything that points me into a direction
maybe I'll slap a bounty on this issue and some wizard can figure it out 😄
Maybe try add
__console.log(new Error("trace").stack)
to the createRequire()
function in node_modules/@cloudflare/vitest-pool-workers/dist/worker/lib/node/module.mjs
?or maybe I should start from scratch and slowly add our stuff, right now it's a wild guessing game
sure
nice, that gives me some new pointers to dig
both lead to use of
crypto
if that rings a bellhmmm, what happens if you log the argument to
createRequire()
too? Or the arguments passed to the function returned from createRequire()
?oh damn,
createRequire
is called in like 20 files 😄All part of the same package?
Some of those will be harmless
It's only when the function returned by
createRequire()
is called you have a problemno, all over the place in vitest and our own code
I don't see any logs from the return function 🙂
which is weird, cause it throws that error 😄
Yeah 😅
let me throw adifferent error
You're definitely using
__console
not console
? (Vitest patches console
with some fancy annotation stuff, __console
is the original unpatched console that logs direct to stdout)yeah
, file:///Users/andreasthomas/github/unkeyed/unkey/node_modules/.pnpm/@[email protected][email protected]/node_modules/@asteasolutions/zod-to-openapi/dist/index.js
it's running here, but I thought I inlined that
Oh interesting, I wonder if inlining is what's causing the issue. Usually
require()
is only called inside "non-inlined" modules returned by the fallback service. How are you marking this module as inline?
I wonder if it's not inlining some of its internal files.like you suggested above
hmmm ok
Hmmm, could you enable
dumpModules
maybe https://vitest.dev/config/#server-debug-dumpmodules and see what the output for zod-to-openapi
is?
I've got to head off now, but thank you for working through this 🙂I might just give up for now 😄
I'll push what I have and add a bounty to it, so someone smarter than me can figure it out 😄
that's one nice thing about oss after all
oh sure, hang on
Gist
_Users_andreasthomas_github_unkeyed_unkey_node_modulespnpm@asteas...
GitHub Gist: instantly share code, notes, and snippets.
it's using require, which I'm guessing is the issue here?
Yeah, interesting the
require()
isn't transformed by Vite 🤔