Skip to content

Commit

Permalink
timers: set several methods EOL
Browse files Browse the repository at this point in the history
PR-URL: #56966
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Rafael Gonzaga <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
  • Loading branch information
anonrig authored Feb 10, 2025
1 parent 3ea97d5 commit 5d7091f
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 262 deletions.
28 changes: 20 additions & 8 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2065,28 +2065,34 @@ method.

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/56966
description: End-of-Life.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/18066
description: Runtime deprecation.
-->

Type: Runtime
Type: End-of-Life

`timers.enroll()` is deprecated. Please use the publicly documented
`timers.enroll()` has been removed. Please use the publicly documented
[`setTimeout()`][] or [`setInterval()`][] instead.

### DEP0096: `timers.unenroll()`

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/56966
description: End-of-Life.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/18066
description: Runtime deprecation.
-->

Type: Runtime
Type: End-of-Life

`timers.unenroll()` is deprecated. Please use the publicly documented
`timers.unenroll()` has been removed. Please use the publicly documented
[`clearTimeout()`][] or [`clearInterval()`][] instead.

### DEP0097: `MakeCallback` with `domain` property
Expand Down Expand Up @@ -2613,14 +2619,17 @@ The `node:_stream_wrap` module is deprecated.

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/56966
description: End-of-Life.
- version: v11.14.0
pr-url: https://github.com/nodejs/node/pull/26760
description: Runtime deprecation.
-->

Type: Runtime
Type: End-of-Life

The previously undocumented `timers.active()` is deprecated.
The previously undocumented `timers.active()` has been removed.
Please use the publicly documented [`timeout.refresh()`][] instead.
If re-referencing the timeout is necessary, [`timeout.ref()`][] can be used
with no performance impact since Node.js 10.
Expand All @@ -2629,14 +2638,17 @@ with no performance impact since Node.js 10.

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/56966
description: End-of-Life.
- version: v11.14.0
pr-url: https://github.com/nodejs/node/pull/26760
description: Runtime deprecation.
-->

Type: Runtime
Type: End-of-Life

The previously undocumented and "private" `timers._unrefActive()` is deprecated.
The previously undocumented and "private" `timers._unrefActive()` has been removed.
Please use the publicly documented [`timeout.refresh()`][] instead.
If unreferencing the timeout is necessary, [`timeout.unref()`][] can be used
with no performance impact since Node.js 10.
Expand Down
35 changes: 0 additions & 35 deletions lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,14 @@ const {
},
kRefed,
kHasPrimitive,
getTimerDuration,
timerListMap,
timerListQueue,
immediateQueue,
active,
unrefActive,
insert,
knownTimersById,
} = require('internal/timers');
const {
promisify: { custom: customPromisify },
deprecate,
} = require('internal/util');
let debug = require('internal/util/debuglog').debuglog('timer', (fn) => {
debug = fn;
Expand Down Expand Up @@ -111,20 +107,6 @@ function unenroll(item) {
item._idleTimeout = -1;
}

// Make a regular object able to act as a timer by setting some properties.
// This function does not start the timer, see `active()`.
// Using existing objects as timers slightly reduces object overhead.
function enroll(item, msecs) {
msecs = getTimerDuration(msecs, 'msecs');

// If this item was already in a list somewhere
// then we should unenroll it from that
if (item._idleNext) unenroll(item);

L.init(item);
item._idleTimeout = msecs;
}


/**
* Schedules the execution of a one-time `callback`
Expand Down Expand Up @@ -351,23 +333,6 @@ module.exports = timers = {
clearImmediate,
setInterval,
clearInterval,
_unrefActive: deprecate(
unrefActive,
'timers._unrefActive() is deprecated.' +
' Please use timeout.refresh() instead.',
'DEP0127'),
active: deprecate(
active,
'timers.active() is deprecated. Please use timeout.refresh() instead.',
'DEP0126'),
unenroll: deprecate(
unenroll,
'timers.unenroll() is deprecated. Please use clearTimeout instead.',
'DEP0096'),
enroll: deprecate(
enroll,
'timers.enroll() is deprecated. Please use setTimeout instead.',
'DEP0095'),
};

ObjectDefineProperties(timers, {
Expand Down
34 changes: 0 additions & 34 deletions test/parallel/test-timers-active.js

This file was deleted.

38 changes: 0 additions & 38 deletions test/parallel/test-timers-enroll-invalid-msecs.js

This file was deleted.

16 changes: 0 additions & 16 deletions test/parallel/test-timers-enroll-second-time.js

This file was deleted.

12 changes: 1 addition & 11 deletions test/parallel/test-timers-max-duration-warning.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const common = require('../common');
const assert = require('assert');
const timers = require('timers');

const OVERFLOW = Math.pow(2, 31); // TIMEOUT_MAX is 2^31-1

Expand All @@ -19,7 +18,7 @@ process.on('warning', common.mustCall((warning) => {
assert.strictEqual(lines[0], `${OVERFLOW} does not fit into a 32-bit signed` +
' integer.');
assert.strictEqual(lines.length, 2);
}, 6));
}, 2));


{
Expand All @@ -31,12 +30,3 @@ process.on('warning', common.mustCall((warning) => {
const interval = setInterval(timerNotCanceled, OVERFLOW);
clearInterval(interval);
}

{
const timer = {
_onTimeout: timerNotCanceled
};
timers.enroll(timer, OVERFLOW);
timers.active(timer);
timers.unenroll(timer);
}
3 changes: 1 addition & 2 deletions test/parallel/test-timers-unenroll-unref-interval.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const common = require('../common');
const timers = require('timers');

{
const interval = setInterval(common.mustCall(() => {
Expand All @@ -17,7 +16,7 @@ const timers = require('timers');

{
const interval = setInterval(common.mustCall(() => {
timers.unenroll(interval);
clearInterval(interval);
}), 1).unref();
}

Expand Down
47 changes: 0 additions & 47 deletions test/parallel/test-timers-unref-active.js

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5d7091f

Please sign in to comment.