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

🐛 BUG: Vitest can not import Stripe #5592

Open
gourgouris opened this issue Apr 11, 2024 · 5 comments
Open

🐛 BUG: Vitest can not import Stripe #5592

gourgouris opened this issue Apr 11, 2024 · 5 comments
Labels
bug Something that isn't working vitest Relating to the Workers Vitest integration

Comments

@gourgouris
Copy link

Which Cloudflare product(s) does this pertain to?

Workers Vitest Integration

What version(s) of the tool(s) are you using?

wrangler: ^3.48.0, vitest: 1.3.0, @cloudflare/vitest-pool-workers: ^0.1.17, stripe: ^14.25.0

What version of Node are you using?

v18.18.2

What operating system and version are you using?

Win 11

Describe the Bug

Observed behavior

When importing Stripe, the runner crashes

Expected behavior

No crash

Steps to reproduce

Go to the official SELF recipe
In linked line add the following code (even inside a test, no difference):

import Stripe from "stripe";
const a = Stripe;

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

image

@gourgouris gourgouris added the bug Something that isn't working label Apr 11, 2024
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Apr 11, 2024
@WalshyDev
Copy link
Member

Looks like this is #5588

@admah admah added the vitest Relating to the Workers Vitest integration label Apr 11, 2024
@gourgouris
Copy link
Author

With @cloudflare/vitest-pool-workers: ^0.2.0 (has #5588) the issue still persists, so maybe they are not related.

@JordanFaust
Copy link

I'm still having this problem as well with a dependency that is importing semver and failing with the same error

@andyjessop andyjessop moved this from Untriaged to Backlog in workers-sdk Aug 9, 2024
@jahands
Copy link
Contributor

jahands commented Sep 21, 2024

I'm having a similar issue with a project that imports @opentelemetry/api and @microlabs/otel-cf-workers:

 FAIL  src/test/auth.spec.ts [ src/test/auth.spec.ts ]
Error: No such module "Users/jh/src/workers/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/os".
  imported from "Users/jh/src/workers/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/HostDetectorSync.js"

edit: Looks like my issue is slightly different: #6581

@gourgouris
Copy link
Author

I had solved this a long time ago, I think it was by adding
alias: { 'call-bind/callBound': new URL('./node_modules/call-bind/index.js', import.meta.url).pathname, },
in vitest config

Just a little rant:
After really trying to make vitest pool workers work for me, I have given up. It feels that cloudflare has given up as well, considering the commits on the release notes and the relevant open PRs.

I am now running a local test environment (ie with some thing similar to `npm run tst) on a side terminal, and instead of SELF.fetch in vitest, I just fetch to localhost:8787.

It runs 10 times faster and it never fails with cryptic c++ errors. I even have console.log, imagine that 😆. Vscode extension works, I can upgrade to latest vitest, source lines work as expected, and I don't need to split test files just because vitest pool workers is unreliable and half of the times hangs.

I even found a very consistently occuring bug in my code around a postgres deadlock detected exception, which I never realized it existed before switching away from vitest pool workers.

Needless to say, this particular issue with Stripe is not even an issue with the approach above..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working vitest Relating to the Workers Vitest integration
Projects
Status: Backlog
Development

No branches or pull requests

5 participants