Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cd98f5d

Browse filesBrowse files
santigimenoMylesBorins
authored andcommitted
test: fix flaky test-http-set-timeout-server
It can happen that the connection and server is closed before the second reponse has been processed by server. In this case, the `res.setTimeout()` callback will never be called causing the test to fail. Fix this by only closing the connection and server when the 2nd has been received. PR-URL: #11790 Fixes: #11768 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
1 parent 0e13887 commit cd98f5d
Copy full SHA for cd98f5d

File tree

Expand file treeCollapse file tree

1 file changed

+8
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-3
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-http-set-timeout-server.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-set-timeout-server.js
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,25 @@ test(function serverRequestNotTimeoutAfterEnd(cb) {
117117

118118
test(function serverResponseTimeoutWithPipeline(cb) {
119119
let caughtTimeout = '';
120+
let secReceived = false;
120121
process.on('exit', function() {
121122
assert.strictEqual(caughtTimeout, '/2');
122123
});
123124
const server = http.createServer(function(req, res) {
125+
if (req.url === '/2')
126+
secReceived = true;
124127
const s = res.setTimeout(50, function() {
125128
caughtTimeout += req.url;
126129
});
127130
assert.ok(s instanceof http.OutgoingMessage);
128131
if (req.url === '/1') res.end();
129132
});
130133
server.on('timeout', function(socket) {
131-
socket.destroy();
132-
server.close();
133-
cb();
134+
if (secReceived) {
135+
socket.destroy();
136+
server.close();
137+
cb();
138+
}
134139
});
135140
server.listen(common.mustCall(function() {
136141
const port = server.address().port;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.