deno
49cf15a0 - fix(ext/node): surface ERR_REQUIRE_ASYNC_MODULE/CYCLE_MODULE codes and fix TLA retry (#34060)

Commit
56 days ago
fix(ext/node): surface ERR_REQUIRE_ASYNC_MODULE/CYCLE_MODULE codes and fix TLA retry (#34060) Tests in node_compat that exercise `require()` of TLA ESM modules were failing because Deno's uncaught-error printer reads `err.name` and `err.message`, while the helpers in `node:module` only set `err.code`. Stderr regexes like `/ERR_REQUIRE_ASYNC_MODULE/` therefore never matched. This adds `ERR_REQUIRE_ASYNC_MODULE` and `ERR_REQUIRE_CYCLE_MODULE` as proper `NodeError` subclasses with `name = "Error [CODE]"` so the printer surfaces the code, and routes the existing helpers through them. Two retry paths in `op_import_sync` also incorrectly let TLA modules through after a previous failure. `do_load_job` was throwing a cycle error for `ModuleStatus::Instantiated`, which masked the TLA case (real cycles are still caught by `import_sync_eval_stack` and the `Instantiating`/`Evaluating` arms). And once a TLA module had been loaded via `await import()`, its status became `Evaluated` and a subsequent `require()` returned the namespace silently; an upfront `is_graph_async()` check now throws `ERR_REQUIRE_ASYNC_MODULE` instead. Six TLA / instantiated-cycle tests are enabled in `tests/node_compat/config.jsonc`. Thirteen further tests are listed as ignored with explicit reasons — nine that depend on Node's implicit CommonJS detection for `.js` files (Deno defaults to ESM), and four gated on Node-specific surfaces Deno doesn't implement (`--experimental-print-required-tla`, `process.features.require_module`, `--require`/`--import` preload, `--trace-require-module` / ExperimentalWarning emissions).
Author
Parents
Loading