Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ext/node): fix argv[1] in Worker #20305

Merged
merged 2 commits into from Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions cli/tests/unit_node/process_test.ts
Expand Up @@ -774,3 +774,15 @@ Deno.test({
assertEquals(process.title, "deno");
},
});

Deno.test({
name: "process.argv[1] in Worker",
async fn() {
const worker = new Worker(
`data:text/javascript,import process from "node:process";console.log(process.argv[1]);`,
{ type: "module" },
);
await delay(10);
worker.terminate();
}
})
2 changes: 1 addition & 1 deletion ext/node/polyfills/process.ts
Expand Up @@ -873,7 +873,7 @@ internals.__bootstrapNodeProcess = function (
// Overwrites the 2st item with getter.
Object.defineProperty(argv, "1", {
get: () => {
if (Deno.mainModule.startsWith("file:")) {
if (Deno.mainModule?.startsWith("file:")) {
return pathFromURL(new URL(Deno.mainModule));
} else {
return join(Deno.cwd(), "$deno$node.js");
Expand Down