Skip to content
Merged
Changes from all commits
Commits
File filter

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: 14 additions & 1 deletion apps/studio/e2e/e2e-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { randomUUID } from 'crypto';
import { tmpdir } from 'os';
import path from 'path';
import { isErrnoException } from '@studio/common/lib/is-errno-exception';
import { findLatestBuild, parseElectronApp } from 'electron-playwright-helpers';
import fs from 'fs-extra';
import { _electron as electron, Page, ElectronApplication } from 'playwright';
Expand Down Expand Up @@ -93,7 +94,19 @@ export class E2ESession {

async cleanup() {
await this.closeApp();
await rimraf( this.sessionPath );
// Retry on ENOTEMPTY: CLI child processes (e.g. copying skills to server-files) may still be
// writing to the session directory briefly after the Electron process exits.
for ( let attempt = 0; attempt < 5; attempt++ ) {
try {
await rimraf( this.sessionPath );
return;
} catch ( error ) {
if ( ! isErrnoException( error ) || error.code !== 'ENOTEMPTY' || attempt === 4 ) {
throw error;
}
await new Promise< void >( ( resolve ) => setTimeout( resolve, 500 ) );
}
}
}

private async launchFirstWindow( testEnv: NodeJS.ProcessEnv = {} ) {
Expand Down
Loading