Skip to content

Commit

Permalink
Inherit stdio in launch + make browsers optional for `update-br…
Browse files Browse the repository at this point in the history
…owsers` (#273)
  • Loading branch information
Domiii authored Nov 15, 2023
2 parents 0c6f165 + 323b86d commit 917cf21
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/replay/src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ commandWithGlobalOptions("rm-all")

commandWithGlobalOptions("update-browsers")
.description("Update browsers used in automation.")
.arguments("<browsers...>")
.arguments("[<browsers...>]")
.action(commandUpdateBrowsers);

commandWithGlobalOptions("upload-sourcemaps")
Expand Down
19 changes: 18 additions & 1 deletion packages/replay/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -832,8 +832,25 @@ async function launchBrowser(
const proc = spawn(execPath, browserArgs[browserName], {
detached: !attach,
env: { ...process.env, RECORD_REPLAY_DIRECTORY: opts?.directory },
stdio: "inherit"
});
proc.unref();
if (!attach) {
proc.unref();
}
else {
// Wait for the browser process to finish.
await new Promise<void>((resolve, reject) => {
proc.on("error", reject);
proc.on("exit", (code, signal) => {
if (code || signal) {
reject(new Error(`Process failed code=${code}, signal=${signal}`));
}
else {
resolve();
}
});
});
}

return proc;
}
Expand Down

0 comments on commit 917cf21

Please sign in to comment.