Skip to content

Handling process exit#1249

Open
sonic16x wants to merge 1 commit into
masterfrom
handling-process-exit
Open

Handling process exit#1249
sonic16x wants to merge 1 commit into
masterfrom
handling-process-exit

Conversation

@sonic16x
Copy link
Copy Markdown
Contributor

fail current running test with specific error before process exit
Screenshot 2026-05-12 at 03 58 56

Comment thread src/testplane.ts
eventsUtils.passthroughEvent(this.runner, this, _.values(MasterSyncEvents));
eventsUtils.passthroughEventAsync(this.runner, this, _.values(MasterAsyncEvents));
eventsUtils.passthroughEventAsync(signalHandler, this, MasterEvents.EXIT);
eventsUtils.passthroughEventAsync(signalHandler, this.runner, MasterEvents.EXIT);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass exit event to runner

Comment thread src/signal-handler.ts
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactoring this to typescript

Comment thread src/signal-handler.ts

let lastCallTime = 0;

const throttleTime = 10;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throttle for SIGINT, by some reason if kill using Control + C event fired twice with delay 7-8ms, probably it is duplicates from webdriver.io

logger.error(`testplane:worker:${child.pid} terminated unexpectedly with ${errMsg}`);
});

this.once(MasterEvents.EXIT, () => child.kill());
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kill child process if get EXIT event from master (through runner)

Comment thread src/runner/index.ts
this.workers = this.registerWorkers(require.resolve("../worker"), ["runTest", "cancel"] as const) as Workers;
this.browserPool = pool.create(this.config, this);

eventsUtils.passthroughEvent(this, this.workersRegistry, MasterEvents.EXIT);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass event to childs

this._emit(MasterEvents.TEST_PASS);
} catch (error) {
this._test.err = error;
this._test.err = this._browser.exitError || error;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use exit error if exist

super(config, opts);

signalHandler.on("exit", () => this.quit());
signalHandler.on("exit", (err?: Error) => this.quit(err));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass error from exit event


async quit(): Promise<void> {
async quit(err?: Error): Promise<void> {
this._exitError = err;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

save in browser for using in test fail

@sonic16x sonic16x force-pushed the handling-process-exit branch from e05cedc to 395f2fa Compare May 11, 2026 21:12
@sonic16x sonic16x force-pushed the handling-process-exit branch from 395f2fa to 8a45901 Compare May 11, 2026 22:15
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor to typescript

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor to typescript

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 11, 2026

Open in StackBlitz

npm i https://pkg.pr.new/gemini-testing/testplane@1249

commit: 8a45901

@sonic16x sonic16x requested a review from shadowusr May 11, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant