You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
consthttps=require("https");// Abort the request after 1 msconstsignal=AbortSignal.timeout(1);// Make the requesthttps.request("https://www.google.co.uk",{ signal }).on("error",(error)=>{console.log(error.message,"CAUSED BY",error.cause?.message);}).on("response",(res)=>{res.on("data",()=>{// do something with the response body}).on("close",()=>console.log("Finished"));}).end();
This doesn't appear to be supported by nock — if I create a scope for https://www.google.co.uk, the request is not aborted after the appropriate time (e.g. if I add a delay using nock).
This appears to be the NodeJS source code that adds support for Abort Signals:
Please avoid duplicates
Context
Since NodeJS 14.17 and 15.3 it has been possible to abort an HTTP(S) request using an
AbortSignal
(see https://nodejs.org/api/http.html#httprequesturl-options-callback).A simple example of this might be:
This doesn't appear to be supported by
nock
— if I create ascope
forhttps://www.google.co.uk
, the request is not aborted after the appropriate time (e.g. if I add a delay usingnock
).This appears to be the NodeJS source code that adds support for Abort Signals:
https://github.com/nodejs/node/blob/259ea3ed59a655ed0263746365c4538ec9c561a5/lib/internal/streams/add-abort-signal.js#L27-L53
Alternatives
No response
If the feature request is accepted, would you be willing to submit a PR?
The text was updated successfully, but these errors were encountered: