Skip to content
Merged
Changes from 2 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
15 changes: 13 additions & 2 deletions packages/playwright/src/worker/workerMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export class WorkerMain extends ProcessRunner {
private _didRunFullCleanup = false;
// Whether the worker was requested to stop.
private _isStopped = false;
// Whether a fatal error was caused by a missing project.
private _isMissingProject = false;
// This promise resolves once the single "run test group" call finishes.
private _runFinished = new ManualPromise<void>();
private _currentTest: TestInfoImpl | null = null;
Expand Down Expand Up @@ -105,6 +107,10 @@ export class WorkerMain extends ProcessRunner {
override async gracefullyClose() {
try {
await this._stop();
if (this._isMissingProject) {
// We never set anything up and we can crash on attempting cleanup
return;
}
// Ignore top-level errors, they are already inside TestInfo.errors.
const fakeTestInfo = new TestInfoImpl(this._config, this._project, this._params, undefined, 0, () => {}, () => {}, () => {});
const runnable = { type: 'teardown' } as const;
Expand Down Expand Up @@ -191,14 +197,19 @@ export class WorkerMain extends ProcessRunner {
return;

this._config = await deserializeConfig(this._params.config);
this._project = this._config.projects.find(p => p.id === this._params.projectId)!;
const project = this._config.projects.find(p => p.id === this._params.projectId);
if (!project) {
this._isMissingProject = true;
throw new Error(`Project with name "${this._params.projectId}" not found. Make sure project name does not change`);
}
this._project = project;
this._poolBuilder = PoolBuilder.createForWorker(this._project);
}

async runTestGroup(runPayload: RunPayload) {
this._runFinished = new ManualPromise<void>();
const entries = new Map(runPayload.entries.map(e => [e.testId, e]));
let fatalUnknownTestIds;
let fatalUnknownTestIds: string[] | undefined;
try {
await this._loadIfNeeded();
const fileSuite = await loadTestFile(runPayload.file, this._config.config.rootDir);
Expand Down
Loading