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
35 changes: 34 additions & 1 deletion src/main/windowsJobObject.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function createMockChild() {
return child;
}

describe.skipIf(process.platform !== "win32")("WindowsJobObjectManager", () => {
describe("WindowsJobObjectManager", () => {
const platformDescriptor = Object.getOwnPropertyDescriptor(process, "platform");

beforeEach(() => {
Expand Down Expand Up @@ -138,6 +138,39 @@ describe.skipIf(process.platform !== "win32")("WindowsJobObjectManager", () => {
await expect(pending).rejects.toThrow(/failed to start/i);
});

it("allows slow helper startup beyond the old five second watchdog", async () => {
vi.useFakeTimers();
const child = createMockChild();
spawnMock.mockReturnValue(child);

const manager = new WindowsJobObjectManager();
const pending = manager.start();

await vi.advanceTimersByTimeAsync(5_000);
child.stdout.write('{"type":"ready"}\n');

await expect(pending).resolves.toBeUndefined();
});

it("rejects startup when the helper never becomes ready", async () => {
vi.useFakeTimers();
const child = createMockChild();
spawnMock.mockReturnValue(child);

const manager = new WindowsJobObjectManager();
const pending = manager.start();
let startupError: unknown;
const handledPending = pending.catch((error: unknown) => {
startupError = error;
});

await vi.advanceTimersByTimeAsync(30_000);

await handledPending;
expect(startupError).toBeInstanceOf(Error);
expect((startupError as Error).message).toMatch(/timed out after 30000ms/i);
});

it("sends an exit command and ends stdin on dispose", async () => {
const child = createMockChild();
const writes: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion src/main/windowsJobObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface HelperErrorMessage {

type HelperMessage = HelperReadyMessage | HelperAssignedMessage | HelperErrorMessage;

const START_TIMEOUT_MS = 5_000;
const START_TIMEOUT_MS = 30_000;
const DISPOSE_GRACE_MS = 500;

function buildHelperScript(): string {
Expand Down