Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions test/automation/pull-requests/pr-review-advisor-openshell.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,26 @@ describe("PR review advisor OpenShell wrapper", () => {
},
);

it("keeps a real Node entrypoint alive while it waits for OpenShell termination (#10791)", () => {
const moduleUrl = new URL("../../../tools/pr-review-advisor/openshell.mts", import.meta.url)
.href;
const child = spawnSync(
process.execPath,
[
"--no-warnings",
"--input-type=module",
"--eval",
`import { waitForAdvisorSandboxTermination } from ${JSON.stringify(moduleUrl)}; await waitForAdvisorSandboxTermination();`,
],
{ encoding: "utf8", killSignal: "SIGTERM", timeout: 1_000 },
);

expect(child.error).toMatchObject({ code: "ETIMEDOUT" });
expect(child.status).toBe(0);
expect(child.signal).toBeNull();
expect(child.stderr).toBe("");
});

it("permits only the pinned image login files required by stable OpenShell exec", () => {
const policy = YAML.parse(
fs.readFileSync("tools/pr-review-advisor/openshell-policy.yaml", "utf8"),
Expand Down
4 changes: 4 additions & 0 deletions tools/pr-review-advisor/openshell.mts
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,11 @@ export function waitForAdvisorSandboxTermination(
signals: AdvisorSandboxSignals = process,
): Promise<void> {
return new Promise((resolve) => {
// Signal listeners and an unresolved promise do not keep Node running when
// no active handles remain. Own one handle until OpenShell terminates PID 1.
const keepAlive = setInterval(() => undefined, 60_000);
const finish = () => {
clearInterval(keepAlive);
signals.removeListener("SIGTERM", finish);
signals.removeListener("SIGINT", finish);
resolve();
Expand Down