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
The promise() function listens for 'finish' and 'error', but dosen't listen for 'close'.
For example, I have a http server, and use json2csv to export a csv. I use toOutput to pipe to http response, then use promise() and wait for the promise. When I start a request and cancel the requset(use postman, for example), the http response emit a 'close' event, but the promise never settle.
Code like this:
const asyncParser = new AsyncParser(opts, transformOpts);
const parsePromise = asyncParser.toOutput(res).promise(); // res is the http response
......
read much data and push to asyncParser.input
......
asyncParser.input.push(null);
await parsePromise // if 'close' event but no 'finish' or 'error' is emitted on res, it will never resolve or reject
Though I can write my own promise listen for 'close' event instead of using promise(). It would be better if it's added in the promise() function in json2csv.
The text was updated successfully, but these errors were encountered:
So I think if the response is sended normally, it will emit 'finish'. But if not, the request is aborted by user for example, it will emit 'close', and I think it's emitted because the socket emits the 'close' event.
The promise() function listens for 'finish' and 'error', but dosen't listen for 'close'.
For example, I have a http server, and use json2csv to export a csv. I use toOutput to pipe to http response, then use promise() and wait for the promise. When I start a request and cancel the requset(use postman, for example), the http response emit a 'close' event, but the promise never settle.
Code like this:
Though I can write my own promise listen for 'close' event instead of using promise(). It would be better if it's added in the promise() function in json2csv.
The text was updated successfully, but these errors were encountered: