deno
ffbc071e - fix(ext/node): add ERR_REQUIRE_ASYNC_MODULE and ERR_REQUIRE_CYCLE_MODULE error codes (#33921)

Commit
102 days ago
fix(ext/node): add ERR_REQUIRE_ASYNC_MODULE and ERR_REQUIRE_CYCLE_MODULE error codes (#33921) **`ERR_REQUIRE_ASYNC_MODULE`:** When `require()` loads an ESM module with top-level await, throw with the proper Node.js error code and message format (`require() cannot be used on an ESM graph with top-level await... Requiring <target>. From <caller>`). **`ERR_REQUIRE_CYCLE_MODULE`:** When `require()` encounters an ESM module in a circular dependency with CJS, throw instead of silently returning `undefined`/partial exports. Detection works by checking `Module._cache` for not-yet-loaded ESM modules (`.mjs` or `"type": "module"` packages). Also adds a Rust-level cycle guard in `op_import_sync` using a thread-local eval stack to catch re-entrant evaluation cycles that V8's module status alone misses. Enables 5 newly passing node_compat tests.
Author
Parents
Loading