diff options
author | Satya Rohith <me@satyarohith.com> | 2024-05-05 19:46:02 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-05 16:16:02 +0200 |
commit | b2628e4a069ed9fc13f34f6e4fd75f29c657e5a9 (patch) | |
tree | 2e55850b36eeca1169ad87c00ffcb7b0b2477924 /runtime | |
parent | d527b635753566e7d01391d675bf010c4856eff9 (diff) |
fix(ext/node): don't rely on Deno.env to read NODE_DEBUG (#23694)
This patch allows implementors to use ext/node without
the need to implement Deno.env API.
Closes https://github.com/denoland/deno/issues/23687
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/js/99_main.js | 40 | ||||
-rw-r--r-- | runtime/worker_bootstrap.rs | 5 |
2 files changed, 29 insertions, 16 deletions
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 59d2a1434..2ea122e34 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -706,12 +706,13 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) { 3: inspectFlag, 5: hasNodeModulesDir, 6: argv0, - 7: shouldDisableDeprecatedApiWarning, - 8: shouldUseVerboseDeprecatedApiWarning, - 9: future, - 10: mode, - 11: servePort, - 12: serveHost, + 7: nodeDebug, + 8: shouldDisableDeprecatedApiWarning, + 9: shouldUseVerboseDeprecatedApiWarning, + 10: future, + 11: mode, + 12: servePort, + 13: serveHost, } = runtimeOptions; if (mode === executionModes.run || mode === executionModes.serve) { @@ -859,7 +860,12 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) { ObjectDefineProperty(globalThis, "Deno", core.propReadOnly(finalDenoNs)); if (nodeBootstrap) { - nodeBootstrap(hasNodeModulesDir, argv0, /* runningOnMainThread */ true); + nodeBootstrap({ + usesLocalNodeModulesDir: hasNodeModulesDir, + runningOnMainThread: true, + argv0, + nodeDebug, + }); } if (future) { delete globalThis.window; @@ -917,9 +923,10 @@ function bootstrapWorkerRuntime( 4: enableTestingFeaturesFlag, 5: hasNodeModulesDir, 6: argv0, - 7: shouldDisableDeprecatedApiWarning, - 8: shouldUseVerboseDeprecatedApiWarning, - 9: future, + 7: nodeDebug, + 8: shouldDisableDeprecatedApiWarning, + 9: shouldUseVerboseDeprecatedApiWarning, + 10: future, } = runtimeOptions; // TODO(iuioiua): remove in Deno v2. This allows us to dynamically delete @@ -1016,13 +1023,14 @@ function bootstrapWorkerRuntime( : undefined; if (nodeBootstrap) { - nodeBootstrap( - hasNodeModulesDir, + nodeBootstrap({ + usesLocalNodeModulesDir: hasNodeModulesDir, + runningOnMainThread: false, argv0, - /* runningOnMainThread */ false, workerId, - workerMetadata, - ); + maybeWorkerMetadata: workerMetadata, + nodeDebug, + }); } if (future) { @@ -1097,4 +1105,4 @@ bootstrapWorkerRuntime( undefined, true, ); -nodeBootstrap(undefined, undefined, undefined, undefined, undefined, true); +nodeBootstrap({ warmup: true }); diff --git a/runtime/worker_bootstrap.rs b/runtime/worker_bootstrap.rs index ee3b81c62..31cb883db 100644 --- a/runtime/worker_bootstrap.rs +++ b/runtime/worker_bootstrap.rs @@ -85,6 +85,7 @@ pub struct BootstrapOptions { pub inspect: bool, pub has_node_modules_dir: bool, pub argv0: Option<String>, + pub node_debug: Option<String>, pub node_ipc_fd: Option<i64>, pub disable_deprecated_api_warning: bool, pub verbose_deprecated_api_warning: bool, @@ -120,6 +121,7 @@ impl Default for BootstrapOptions { args: Default::default(), has_node_modules_dir: Default::default(), argv0: None, + node_debug: None, node_ipc_fd: None, disable_deprecated_api_warning: false, verbose_deprecated_api_warning: false, @@ -156,6 +158,8 @@ struct BootstrapV8<'a>( bool, // argv0 Option<&'a str>, + // node_debug + Option<&'a str>, // disable_deprecated_api_warning, bool, // verbose_deprecated_api_warning @@ -187,6 +191,7 @@ impl BootstrapOptions { self.enable_testing_features, self.has_node_modules_dir, self.argv0.as_deref(), + self.node_debug.as_deref(), self.disable_deprecated_api_warning, self.verbose_deprecated_api_warning, self.future, |