From 6fedd50b8e4e9874128879a6f8d828667c3ecac1 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Sat, 23 Dec 2023 10:58:53 +0100 Subject: [PATCH] lib: run microtasks before ticks This resolve multiple timing issues related to promises and nextTick. As well as resolving zaldo in promise only code, i.e. our current best practice of using process.nextTick will always apply and work. Refs: https://github.com/nodejs/node/issues/51156 Refs: https://github.com/nodejs/node/issues/51156#issuecomment-1864656761 Refs: https://github.com/nodejs/node/pull/51114 Refs: https://github.com/nodejs/node/pull/51070 Refs: https://github.com/nodejs/node/issues/51156 PR-URL: https://github.com/nodejs/node/pull/51267 --- doc/api/cli.md | 15 +++++++++++++++ lib/internal/process/task_queues.js | 13 ++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/doc/api/cli.md b/doc/api/cli.md index c17af97f38b3fd..da3e9691eba6c1 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -789,6 +789,21 @@ about [this configuration][`--experimental-sea-config`] for details. ### `--experimental-shadow-realm` +### `--experimental-task-ordering` + +Enable experimental task ordering. Always drain micro task queue +before running `process.nextTick` to avoid unintuitive behavior +and unexpected logical deadlocks when mixing async callback and +event API's with `Promise`, `async`/`await`` and `queueMicroTask`. + + + +> Stability: 1 - Experimental + + +