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

timeout error when testing fetch with nock #3624

Closed
6 tasks done
rburgst opened this issue Jun 19, 2023 · 9 comments
Closed
6 tasks done

timeout error when testing fetch with nock #3624

rburgst opened this issue Jun 19, 2023 · 9 comments

Comments

@rburgst
Copy link

rburgst commented Jun 19, 2023

Describe the bug

when mocking network requests with nock then vitest produces a timeout where jest works without problems.
Any help would be appreciated

Reproduction

https://replit.com/@rburgst/vitest-nock-problem?v=1
https://stackblitz.com/edit/vitest-dev-vitest-khkmge?file=test%2Fnock.test.ts

  1. on the right hand side choose the "Shell" tab
  2. run npm install
  3. run npm test

expected

the test should succeed and log the fetch result

actual

the test times out after 5s

System Info

System:
    OS: Linux 5.19 Ubuntu 20.04.2 LTS (Focal Fossa)
    CPU: (8) x64 AMD EPYC 7B12
    Memory: 34.90 GB / 62.79 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 18.12.1 - /nix/store/dj805sw07vvpbxx39c8g67x8qddg0ikw-nodejs-18.12.1/bin/node
    Yarn: 1.22.19 - /nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/bin/yarn
    npm: 8.19.2 - /nix/store/dj805sw07vvpbxx39c8g67x8qddg0ikw-nodejs-18.12.1/bin/npm
  npmPackages:
    vite: ^4.3.9 => 4.3.9 
    vitest: ^0.32.2 => 0.32.2

Used Package Manager

yarn

Validations

@rburgst
Copy link
Author

rburgst commented Jun 27, 2023

anyone home?

@VelizarDemirev
Copy link

It would be nice to see some response here

@AriPerkkio
Copy link
Member

Could you convert the repl.it repro to Github repository or Stackblitz?

@panzerdp
Copy link

Unfortunately having the same problem. Some details can be found here.

@PiotrBryla
Copy link

I have the same problem.

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Feb 29, 2024

I'm not familiar with nock but it looks like they don't have a stable support with fetch yet:

With the latest stable (13.5.4), it doesn't timeout anymore but it looks like an error from nock:
(EDIT: actually this times out when running it locally on my PC. error might be only on stackblitz)
https://stackblitz.com/edit/vitest-dev-vitest-khkmge?file=test%2Fnock.test.ts

Then, I tested with beta (14.0.0-beta.4) and this one looks working for me:
https://stackblitz.com/edit/vitest-dev-vitest-htb8gx?file=test%2Fnock.test.ts

I'm not sure how Jest has made it work, but I don't think there's anything actionable from Vitest for this issue.
Please provide a reproduction if anyone on this issue sees something different from the examples I made on stackblitz above.

Copy link

Hello @rburgst. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.

@rburgst
Copy link
Author

rburgst commented Feb 29, 2024

@hi-ogawa
Copy link
Contributor

@rburgst I think this error is simply due to nock's limitation in v13. That's why I wrote that there's nothing actionable from Vitest side. Can you try v14 (beta) to see if it works for you?

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 4, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants