deno
e7e1606c - fix(runtime): suggest Worker/node:vm alternatives for npm:isolated-vm (#34702)

Commit
59 days ago
fix(runtime): suggest Worker/node:vm alternatives for npm:isolated-vm (#34702) ## What `npm:isolated-vm` cannot run in Deno: it is a native addon built directly on V8's C++ internals, which Deno does not expose. Users hit it in one of two ways: 1. `error: Uncaught Error: Cannot find module './out/isolated_vm'` — the package's entry point does `require('./out/isolated_vm')` and the native addon was never built (the case reported in #25130). 2. If the addon is built, it fails with the legacy native addon ABI error from `ext/napi` (it registers via `NODE_MODULE`/`nan`, not Node-API). Either way it cannot be loaded, and today the user is left with a bare `Cannot find module` error and no guidance — the issue explicitly asks "What is the best way to run a child that does not crash the main thread?" ## Change This follows the established pattern in `runtime/fmt_errors.rs` (`get_suggestions_for_terminal_errors`) used for other unsupported native addons (canvas/libxmljs bindings, better-sqlite3, legacy V8/nan addons in #34695). It adds a dedicated branch that detects either `isolated-vm` failure mode and prints an actionable suggestion: ``` info: `isolated-vm` is a native addon built directly on V8's C++ internals, which Deno does not expose, so it cannot be loaded in Deno. hint: To run code in a separate isolate, use a `Worker`: it executes in its own isolate and thread and can be sandboxed via the `deno.permissions` option. For in-process sandboxing, the `node:vm` module is also available. ``` ## Tests New spec test `tests/specs/run/isolated_vm_suggestion` covering both the module-not-found and legacy-addon-ABI paths. Closes #25130 Closes denoland/divybot#415 Co-authored-by: divybot <divybot@users.noreply.github.com> Co-authored-by: Divy Srivastava <me@littledivy.com>
Author
Parents
Loading