GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — timers: fix arbitrary object clearImmediate errors · nodejs/node@e4d1042

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • internal
      • timers.js
    • timers.js
  • test/parallel
    • test-repl-clear-immediate-crash.js
    • test-timers-clear-object-does-not-throw-error.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/timers.js‎

Copy file name to clipboardExpand all lines: lib/internal/timers.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,11 @@ ImmediateList.prototype.append = function(item) {
275275
// Removes an item from the linked list, adjusting the pointers of adjacent
276276
// items and the linked list's head or tail pointers as necessary
277277
ImmediateList.prototype.remove = function(item) {
278-
if (item._idleNext !== null) {
278+
if (item._idleNext) {
279279
item._idleNext._idlePrev = item._idlePrev;
280280
}
281281

282-
if (item._idlePrev !== null) {
282+
if (item._idlePrev) {
283283
item._idlePrev._idleNext = item._idleNext;
284284
}
285285

Collapse file

‎lib/timers.js‎

Copy file name to clipboardExpand all lines: lib/timers.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ function clearImmediate(immediate) {
283283
toggleImmediateRef(false);
284284
immediate[kRefed] = null;
285285

286-
if (destroyHooksExist()) {
286+
if (destroyHooksExist() && immediate[async_id_symbol] !== undefined) {
287287
emitDestroy(immediate[async_id_symbol]);
288288
}
289289

Collapse file

‎test/parallel/test-repl-clear-immediate-crash.js‎

Copy file name to clipboard
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
const common = require('../common');
3+
const child_process = require('child_process');
4+
const assert = require('assert');
5+
6+
// Regression test for https://github.com/nodejs/node/issues/37806:
7+
const proc = child_process.spawn(process.execPath, ['-i']);
8+
proc.on('error', common.mustNotCall());
9+
proc.on('exit', common.mustCall((code) => {
10+
assert.strictEqual(code, 0);
11+
}));
12+
proc.stdin.write('clearImmediate({});\n.exit\n');
Collapse file

‎test/parallel/test-timers-clear-object-does-not-throw-error.js‎

Copy file name to clipboard
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
require('../common');
3+
4+
// This test makes sure clearing timers with
5+
// objects doesn't throw
6+
clearImmediate({});
7+
clearTimeout({});
8+
clearInterval({});

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.