I'm trying to use phin for testing edge cases during the HTTP server shutdown and discovered that a request made with phin will hang forever if it's aborted before the transfer is complete. Here's a minimal reproducible code snippet showing this behaviour:
"use strict";
const phin = require("phin");
const http = require("http");
const util = require("util");
async function test() {
let server = http.createServer();
await util.promisify(server.listen.bind(server))();
server.on("request", (req, res) => {
// write some data, then abort the connection
res.write("partial", () => {
res.socket.destroy();
});
});
// hangs forever
await phin(`http://localhost:${server.address().port}/`);
console.log("never reached");
}
test().catch(console.log);
It appears that this is not properly handled in CentraRequest.js: there's handlers added for error and end events of the incommingMessage stream, but an aborted connections does not raise either of these. There's a separate aborted event for this situation.
I'm trying to use phin for testing edge cases during the HTTP server shutdown and discovered that a request made with phin will hang forever if it's aborted before the transfer is complete. Here's a minimal reproducible code snippet showing this behaviour:
It appears that this is not properly handled in CentraRequest.js: there's handlers added for
error
andend
events of the incommingMessage stream, but an aborted connections does not raise either of these. There's a separateaborted
event for this situation.