-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: make sure clear the old timer in http server
PR-URL: #52118 Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const http = require('http'); | ||
const assert = require('assert'); | ||
const { kConnectionsCheckingInterval } = require('_http_server'); | ||
|
||
let i = 0; | ||
let timer; | ||
const server = http.createServer(); | ||
server.on('listening', common.mustCall(() => { | ||
// If there was a timer, it must be destroyed | ||
if (timer) { | ||
assert.ok(timer._destroyed); | ||
} | ||
// Save the last timer | ||
timer = server[kConnectionsCheckingInterval]; | ||
if (++i === 2) { | ||
server.close(() => { | ||
assert.ok(timer._destroyed); | ||
}); | ||
} | ||
}, 2)); | ||
server.emit('listening'); | ||
server.emit('listening'); |