Skip to content

require() of a builtin demotes process.nextTick below promise microtasks #9412

Description

@proggeramlug
require("path");                      // <-- delete this line and perry matches node
const o = [];
process.nextTick(() => o.push("nextTick"));
Promise.resolve().then(() => o.push("p1"));
(async () => { await null; o.push("await"); })();
setTimeout(() => console.log(JSON.stringify(o)), 20);

// node:  ["nextTick","p1","await"]
// perry: ["p1","await","nextTick"]

process.nextTick callbacks must run before promise microtasks. After any require() of a builtin, perry runs them after.

Deterministic: 5/5 with the require, 3/3 matching node without it.

Why no fixture caught it

Every real bundle requires builtins, and every minimal fixture doesn't — so the ordering is correct in exactly the programs a test suite contains and wrong in exactly the programs users run.

Excluded from this report

setTimeout-vs-setImmediate ordering also differed, but node is itself nondeterministic there, so it is not filed as a bug.

Found by a differential stress-test of claude-code under perry.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions