From f44498538fc6d700d921ec10481fc3b3fb905449 Mon Sep 17 00:00:00 2001 From: Nitzan Uziely Date: Sat, 20 Mar 2021 03:43:06 +0200 Subject: [PATCH] fixup! timers: fix arbitrary object clearImmediate errors --- test/parallel/test-repl-clear-immediate-crash.js | 12 ++++++++++++ .../test-timers-clear-object-does-not-throw-error.js | 8 ++++++++ 2 files changed, 20 insertions(+) create mode 100644 test/parallel/test-repl-clear-immediate-crash.js create mode 100644 test/parallel/test-timers-clear-object-does-not-throw-error.js diff --git a/test/parallel/test-repl-clear-immediate-crash.js b/test/parallel/test-repl-clear-immediate-crash.js new file mode 100644 index 00000000000000..ce8aaf48e7fa0e --- /dev/null +++ b/test/parallel/test-repl-clear-immediate-crash.js @@ -0,0 +1,12 @@ +'use strict'; +const common = require('../common'); +const child_process = require('child_process'); +const assert = require('assert'); + +// Regression test for https://github.com/nodejs/node/issues/37806: +const proc = child_process.spawn(process.execPath, ['-i']); +proc.on('error', common.mustNotCall()); +proc.on('exit', common.mustCall((code) => { + assert.strictEqual(code, 0); +})); +proc.stdin.write('clearImmediate({});\n.exit\n'); diff --git a/test/parallel/test-timers-clear-object-does-not-throw-error.js b/test/parallel/test-timers-clear-object-does-not-throw-error.js new file mode 100644 index 00000000000000..9752f53abd0755 --- /dev/null +++ b/test/parallel/test-timers-clear-object-does-not-throw-error.js @@ -0,0 +1,8 @@ +'use strict'; +require('../common'); + +// This test makes sure clearing timers with +// objects doesn't throw +clearImmediate({}); +clearTimeout({}); +clearInterval({});