Skip to content

delayBody doesn't work with abort signal ([email protected]) #2808

@sam-super

Description

@sam-super

Please avoid duplicates

Reproducible test case

https://gist.github.com/sam-super/1706b4e46a92a9d3ec64a13ee7c7d3ca

Nock Version

14.0.0-beta.16

Node Version

v22.11.0

TypeScript Version

No response

What happened?

Unlike nock v13 (with node-fetch package) delayBody doesn't work correctly with 14.0.0-beta.16 using node's native fetch.

this gist compares using nock vs spinning up a nodejs server to delay the response body. if you run it you should get this:

node version: v22.11.0
 ---------- node test ----------
response received after 0.01s
NODE: Correctly threw error after timeout: TimeoutError: The operation was aborted due to timeout
 ---------- /node test ---------
 ---------- nock test ----------
response received after 0.008s
body received after 1.209s
NOCK: BUG - got a successful response in spite of setting AbortSignal.timeout(1000) and response delay of 1200: NockResBody
 ---------- /nock test ---------

in case it helps delayConnection works in 14.0.0-beta.16 (however in 14.0.0-beta.7 delayConnection didn't work).

Would you be interested in contributing a fix?

  • yes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions