-
Notifications
You must be signed in to change notification settings - Fork 239
Description
Something is fishy with Needle and redirects on Node 8.12.0!
Remote end closed socket abruptly
The issue does not seem to appear with Node 4.x, 6.x, 9.x or 10.x.
I've put together the smallest example I could that demonstrates the problem (please excuse the gross style.. I wanted to check Node 4 behaviour):
var needle = require('needle');
var express = require('express');
var app = express();
var port = 3000;
app.get('/', (req, res) => res.send('Hello World!'));
app.get('/redirector', (req, res) => res.redirect('/'));
var server = app.listen(port, () => {
console.log(`NodeJS version ${process.version}`);
console.log(`Example app listening on port ${port}!`);
needle('get', 'http://localhost:3000/redirector', {}, {
'follow_max': 5,
})
.then(res => {
console.log('Worked with redirect:', res.body === 'Hello World!');
})
.catch(e => {
console.log(`Redirect failed on NodeJS version ${process.version}`);
console.error(e);
})
.then(() => server.close());
});I mostly tested with Express 4.16.3 and Needle 2.2.3, but tried a few combinations with the same results as below:
NodeJS version v4.9.1
Example app listening on port 3000!
Worked with redirect: true
NodeJS version v6.14.3
Example app listening on port 3000!
Worked with redirect: true
NodeJS version v8.11.4
Example app listening on port 3000!
Worked with redirect: true
NodeJS version v8.12.0
Example app listening on port 3000!
Redirect failed on NodeJS version v8.12.0
Error: Remote end closed socket abruptly. <----- BOOOOO!
NodeJS version v9.11.2
Example app listening on port 3000!
Worked with redirect: true
NodeJS version v10.10.0
Example app listening on port 3000!
Worked with redirect: trueSo, what is going on with Node 8.12.0? 8.11.4 works just fine.
Perhaps something to do with no longer calling maybeDestroy(this)?: https://github.com/nodejs/node/pull/18708/files
But I'd expect that to cause us problems with Node 10.x too.
Please let me know if I can provide any further details, and thanks for the great library 😺
P.S. The example code has both Express and Needle running on the same version of Node for simplicity. I have tested with running the Express server on Node 8.11.4 and hitting it from Needle running on 8.12.0 to rule out an issue with the server side of things.