Skip to content

Commit f94eec0

Browse files
Fishrock123BridgeAR
authored andcommitted
http: convert utcDate to use setTimeout
A sort-of follow-up to #17704, this removes the last internal use of enroll(). PR-URL: #17800 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 8578fe2 commit f94eec0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/internal/http.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
'use strict';
22

3-
const timers = require('timers');
3+
const { setUnrefTimeout } = require('internal/timers');
44

55
var dateCache;
66
function utcDate() {
77
if (!dateCache) {
88
const d = new Date();
99
dateCache = d.toUTCString();
10-
timers.enroll(utcDate, 1000 - d.getMilliseconds());
11-
timers._unrefActive(utcDate);
10+
11+
setUnrefTimeout(resetCache, 1000 - d.getMilliseconds());
1212
}
1313
return dateCache;
1414
}
15-
utcDate._onTimeout = function() {
15+
16+
function resetCache() {
1617
dateCache = undefined;
17-
};
18+
}
1819

1920
function ondrain() {
2021
if (this._httpMessage) this._httpMessage.emit('drain');

0 commit comments

Comments
 (0)