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
In some scenarios promise returned by e.g.response.text() resolves before 'close' event is emitted on Node.js response object (as emitted with requests's 'response' event).
It's not an issue per se, but:
Not sure if that's on par with how Fetch works in a browser.
It seems not possible to observe an async request/response process as a whole (it finalizes with 'close' event emitted on response, which is not exposed and ignored by node-fetch internals). It's an issue when e.g. we want to detect orphaned async flows, and for that want to guarantee that promises returned by fetch do not resolve prior response closes.
For example following test case will report an async leak in Node.js v12.2, when using node-fetch at v2.6.0
constfetch=require('node-fetch');constcheckAsyncLeak=()=>setTimeout(()=>{thrownewError('Async leak!');}).unref();fetch('https://google.com',{compress: false}).then(response=>response.text()).then(()=>{// All request related async jobs should be finalized by nowcheckAsyncLeak();});
The text was updated successfully, but these errors were encountered:
In some scenarios promise returned by e.g.
response.text()
resolves before'close'
event is emitted on Node.js response object (as emitted with requests's'response'
event).It's not an issue per se, but:
Fetch
works in a browser.'close'
event emitted onresponse
, which is not exposed and ignored bynode-fetch
internals). It's an issue when e.g. we want to detect orphaned async flows, and for that want to guarantee that promises returned byfetch
do not resolve prior response closes.For example following test case will report an async leak in Node.js v12.2, when using
node-fetch
at v2.6.0The text was updated successfully, but these errors were encountered: