Skip to content

Commit 1672f00

Browse files
committed
http: convert utcDate to use setTimeout
A sort-of follow-up to nodejs#17704, this removes the last internal use of enroll().
1 parent fc61ee3 commit 1672f00

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(timeout, 1000 - d.getMilliseconds());
1212
}
1313
return dateCache;
1414
}
15-
utcDate._onTimeout = function() {
15+
16+
function timeout() {
1617
dateCache = undefined;
17-
};
18+
}
1819

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

0 commit comments

Comments
 (0)