mirror of
https://github.com/microsoft/playwright-mcp.git
synced 2025-07-26 08:32:26 +08:00
Fix race condition in session file initialization by chaining file operations
Co-authored-by: pavelfeldman <883973+pavelfeldman@users.noreply.github.com>
This commit is contained in:
parent
9588845cc3
commit
bb9de30ef9
@ -45,6 +45,7 @@ export class Context {
|
||||
private _pendingAction: PendingAction | undefined;
|
||||
private _downloads: { download: playwright.Download, finished: boolean, outputFile: string }[] = [];
|
||||
private _sessionFile: string | undefined;
|
||||
private _sessionFileInitialized: Promise<void> | undefined;
|
||||
clientVersion: { name: string; version: string; } | undefined;
|
||||
|
||||
constructor(tools: Tool[], config: FullConfig, browserContextFactory: BrowserContextFactory) {
|
||||
@ -53,7 +54,7 @@ export class Context {
|
||||
this._browserContextFactory = browserContextFactory;
|
||||
testDebug('create context');
|
||||
if (this.config.saveSession)
|
||||
void this._initializeSessionFile();
|
||||
this._sessionFileInitialized = this._initializeSessionFile();
|
||||
}
|
||||
|
||||
clientSupportsImages(): boolean {
|
||||
@ -150,6 +151,10 @@ export class Context {
|
||||
if (!this.config.saveSession || !this._sessionFile)
|
||||
return;
|
||||
|
||||
// Ensure session file is initialized before proceeding
|
||||
if (this._sessionFileInitialized)
|
||||
await this._sessionFileInitialized;
|
||||
|
||||
const entry = [
|
||||
`- ${toolName}:`,
|
||||
' params:',
|
||||
|
Loading…
x
Reference in New Issue
Block a user