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

i.match is not a function when {allowUnmocked: true} in 14.0.0-beta.7 #2758

Closed
1 of 2 tasks
kuzdogan opened this issue Jul 5, 2024 · 5 comments
Closed
1 of 2 tasks
Labels

Comments

@kuzdogan
Copy link

kuzdogan commented Jul 5, 2024

Please avoid duplicates

Reproducible test case

ethereum/sourcify#1465

Nock Version

14.0.0-beta.7

Node Version

20.12.2

TypeScript Version

5.5.3

What happened?

We are using native fetch with Node v20. When mocking a single path but allowing other requests I receive the error:

     Uncaught TypeError: i.match is not a function
      at /Users/kuzdogan/repos/sourcify/node_modules/nock/lib/intercepted_request_router.js:304:9
      at Array.find (<anonymous>)
      at InterceptedRequestRouter.startPlayback (/Users/kuzdogan/repos/sourcify/node_modules/nock/lib/intercepted_request_router.js:303:45)
      at InterceptedRequestRouter.maybeStartPlayback (/Users/kuzdogan/repos/sourcify/node_modules/nock/lib/intercepted_request_router.js:268:12)
      at InterceptedRequestRouter.connectSocket (/Users/kuzdogan/repos/sourcify/node_modules/nock/lib/intercepted_request_router.js:140:12)
      at /Users/kuzdogan/repos/sourcify/node_modules/nock/lib/intercepted_request_router.js:78:33
      at processTicksAndRejections (node:internal/process/task_queues:77:11)

The error can be reproduced at the PR/branch above. Check out the branch, run npm i and run npx mocha services/server/test/unit/VerificationService.spec.ts

Would you be interested in contributing a fix?

  • yes
@kuzdogan kuzdogan added the bug label Jul 5, 2024
@mikicho
Copy link
Contributor

mikicho commented Jul 13, 2024

We published a new version. Can you please give it a try?
Please note that we no longer support the fast-throw for the delay feature, and there is a small regression for compressed responses that we hope to close soon (mswjs/interceptors#604).

Full changelog

@kuzdogan
Copy link
Author

The issue seems to be resolved, thanks

@kuzdogan
Copy link
Author

Unfortunately opening this again since there seems to be another issue.

This time it seems to be related to @mswjs/interceptors.

[email protected] /Users/kuzdogan/repos/sourcify
└─┬ [email protected] -> ./services/server
  └─┬ [email protected]
    └── @mswjs/[email protected]

When running the tests we are getting Request with GET/HEAD method cannot have body.: https://app.circleci.com/pipelines/github/ethereum/sourcify/6404/workflows/f43896c5-c598-45e3-82d3-a6b476cef8f7/jobs/38636

The tests that are failing are actually GET requests with empty bodies and no mocking but somehow the requests get messed up. LMK if you need more instructions for reproduction

@kuzdogan kuzdogan reopened this Jul 15, 2024
@mikicho
Copy link
Contributor

mikicho commented Jul 15, 2024

@kuzdogan can you please open a new issue instead?
Also, can you please paste in the issue how to reproduce this?

We have a test a simple case:

it('input is string', async () => {
  const scope = nock('http:https://example.test').get('/').reply()

  const { status } = await fetch('http:https://example.test/')
  expect(status).to.equal(200)
  scope.done()
})

@mikicho
Copy link
Contributor

mikicho commented Jul 16, 2024

I'm closing this one. Feel free to open another one with the new issue with a reproduce.

@mikicho mikicho closed this as completed Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants