diff --git a/lib/internal/http.js b/lib/internal/http.js index 71e32498f359a1..2b9c948aeefb30 100644 --- a/lib/internal/http.js +++ b/lib/internal/http.js @@ -1,20 +1,21 @@ 'use strict'; -const timers = require('timers'); +const { setUnrefTimeout } = require('internal/timers'); var dateCache; function utcDate() { if (!dateCache) { const d = new Date(); dateCache = d.toUTCString(); - timers.enroll(utcDate, 1000 - d.getMilliseconds()); - timers._unrefActive(utcDate); + + setUnrefTimeout(resetCache, 1000 - d.getMilliseconds()); } return dateCache; } -utcDate._onTimeout = function() { + +function resetCache() { dateCache = undefined; -}; +} function ondrain() { if (this._httpMessage) this._httpMessage.emit('drain');