diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-02-15 19:44:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-15 19:44:52 +0100 |
commit | 75209e12f19ca5d4a2a7c9008fba63a487ad8e6a (patch) | |
tree | c122feabbceeef070de4d4eb23667c6153ea7eb1 /core/runtime.rs | |
parent | c4b9a91e27a32c0949688034c2449936c01a44a9 (diff) |
feat: wire up ext/node to the Node compatibility layer (#17785)
This PR changes Node.js/npm compatibility layer to use polyfills for
built-in Node.js
embedded in the snapshot (that are coming from "ext/node" extension).
As a result loading `std/node`, either from
"https://deno.land/std@<latest>/" or
from "DENO_NODE_COMPAT_URL" env variable were removed. All code that is
imported via "npm:" specifiers now uses code embedded in the snapshot.
Several fixes were applied to various modules in "ext/node" to make
tests pass.
---------
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Diffstat (limited to 'core/runtime.rs')
-rw-r--r-- | core/runtime.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/runtime.rs b/core/runtime.rs index 0127e80e6..a2b011362 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -841,7 +841,14 @@ impl JsRuntime { ) .await?; let receiver = runtime.mod_evaluate(id); - runtime.run_event_loop(false).await?; + poll_fn(|cx| { + let r = runtime.poll_event_loop(cx, false); + // TODO(bartlomieju): some code in readable-stream polyfill in `ext/node` + // is calling `nextTick()` during snapshotting, which causes infinite loop + runtime.state.borrow_mut().has_tick_scheduled = false; + r + }) + .await?; receiver.await? }) .with_context(|| format!("Couldn't execute '{}'", file_source.specifier)) @@ -2532,7 +2539,6 @@ impl JsRuntime { let tc_scope = &mut v8::TryCatch::new(scope); let this = v8::undefined(tc_scope).into(); js_nexttick_cb.call(tc_scope, this, &[]); - if let Some(exception) = tc_scope.exception() { return exception_to_err_result(tc_scope, exception, false); } |