Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: remove err timer from test-http-set-timeout #9264

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 13 additions & 19 deletions test/parallel/test-http-set-timeout.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
var net = require('net');
const common = require('../common');
const assert = require('assert');
const http = require('http');
const net = require('net');

var server = http.createServer(function(req, res) {
console.log('got request. setting 1 second timeout');
var s = req.connection.setTimeout(500);
assert.ok(s instanceof net.Socket);
req.connection.on('timeout', function() {
console.log('got request. setting 500ms timeout');
var socket = req.connection.setTimeout(500);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these vars be const as well? It seems a little weird to make them constant, but if they don't change...

assert.ok(socket instanceof net.Socket);
req.connection.on('timeout', common.mustCall(function() {
req.connection.destroy();
console.error('TIMEOUT');
server.close();
});
}));
});

server.listen(0, function() {
console.log(`Server running at http://127.0.0.1:${this.address().port}/`);

var errorTimer = setTimeout(function() {
throw new Error('Timeout was not successful');
}, common.platformTimeout(2000));

var x = http.get({port: this.address().port, path: '/'});
x.on('error', function() {
clearTimeout(errorTimer);
var request = http.get({port: this.address().port, path: '/'});
request.on('error', common.mustCall(function() {
console.log('HTTP REQUEST COMPLETE (this is good)');
});
x.end();

}));
request.end();
});