diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-02-16 14:30:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-16 14:30:14 +0100 |
commit | 4c2380af5c8561fc0a5f8279c1c7336680d026ed (patch) | |
tree | 616a0405b8aead38803ea7f893302a87b5001a5d /ext/node/polyfills/_next_tick.ts | |
parent | 848e2c0d57febf744ed585702f314dc64bc8b4ae (diff) |
test: add unit tests from std/node (#17794)
Adds two test files: "cli/tests/unit_node/process_test.ts" and
"cli/tests/unit_node/child_process_test.ts"
---------
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
Diffstat (limited to 'ext/node/polyfills/_next_tick.ts')
-rw-r--r-- | ext/node/polyfills/_next_tick.ts | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/ext/node/polyfills/_next_tick.ts b/ext/node/polyfills/_next_tick.ts index d5aa88218..72a6fc120 100644 --- a/ext/node/polyfills/_next_tick.ts +++ b/ext/node/polyfills/_next_tick.ts @@ -11,6 +11,11 @@ interface Tock { args: Array<unknown>; } +let nextTickEnabled = false; +export function enableNextTick() { + nextTickEnabled = true; +} + const queue = new FixedQueue(); export function processTicksAndRejections() { @@ -71,8 +76,6 @@ export function runNextTicks() { // return; if (!core.hasTickScheduled()) { core.runMicrotasks(); - } - if (!core.hasTickScheduled()) { return true; } @@ -93,6 +96,12 @@ export function nextTick<T extends Array<unknown>>( callback: (...args: T) => void, ...args: T ) { + // If we're snapshotting we don't want to push nextTick to be run. We'll + // enable next ticks in "__bootstrapNodeProcess()"; + if (!nextTickEnabled) { + return; + } + validateFunction(callback, "callback"); if (_exiting) { |