Skip to content

Commit 5e6d1dd

Browse files
committed
rebase
1 parent ccb7c92 commit 5e6d1dd

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

packages/playwright-core/bin/webkit-wsl-pipe-wrapper.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
// @ts-check
22
import net from 'net';
3+
import fs from 'fs';
34
import { execSync, spawn } from 'child_process';
45

56
const socketPort = process.env.PW_WKWSL_PORT;
67
delete process.env.PW_WKWSL_PORT;
78
if (!socketPort)
89
throw new Error('PW_WKWSL_PORT env var is not set');
910

11+
const [executable, ...args] = process.argv.slice(2);
12+
13+
if (!(await fs.promises.stat(executable)).isFile())
14+
throw new Error(`Executable does not exist. Did you update Playwright recently? Make sure to run npx playwright install webkit-wsl`);
15+
1016
const address = (() => {
1117
if (execSync('wslinfo --networking-mode', { encoding: 'utf8' }).trim() === 'nat') {
1218
const ip = execSync('ip route show', { encoding: 'utf8' }).trim().split('\n').find(line => line.includes('default'))?.split(' ')[2];
@@ -25,8 +31,6 @@ await new Promise((resolve, reject) => {
2531
socket.on('error', reject);
2632
});
2733

28-
const [executable, ...args] = process.argv.slice(2);
29-
3034
// 3 is readFD and 4 is writeFD
3135
const child = spawn(executable, args, {
3236
stdio: ['inherit', 'inherit', 'inherit', 'pipe', 'pipe']

packages/playwright-core/src/server/browserType.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export abstract class BrowserType extends SdkObject {
272272
if (options.cdpPort !== undefined || !this.supportsPipeTransport())
273273
transport = await WebSocketTransport.connect(progress, wsEndpoint!);
274274
else
275-
transport = new PipeTransport(processLifecycleHooks.writePipe(launchedProcess), processLifecycleHooks.readPipe(launchedProcess));
275+
transport = processLifecycleHooks.createTransport(launchedProcess);
276276
return { browserProcess, artifactsDir: prepared.artifactsDir, userDataDir: prepared.userDataDir, transport };
277277
} catch (error) {
278278
transport?.close();
@@ -353,8 +353,9 @@ export abstract class BrowserType extends SdkObject {
353353
preLaunch: async () => {},
354354
onExit: async () => {},
355355
amendEnvironment: async env => env,
356-
readPipe: p => p.stdio[4] as NodeJS.ReadableStream,
357-
writePipe: p => p.stdio[3] as NodeJS.WritableStream,
356+
createTransport(p): ConnectionTransport {
357+
return new PipeTransport(p.stdio[3] as NodeJS.WritableStream, p.stdio[4] as NodeJS.ReadableStream);
358+
}
358359
};
359360
}
360361
}
@@ -363,8 +364,7 @@ export type LaunchLifecycleHooks = {
363364
preLaunch(): Promise<void>;
364365
onExit(): Promise<void>;
365366
amendEnvironment(env: Env, options: types.LaunchOptions, userDataDir: string, isPersistent: boolean): Promise<Env>;
366-
readPipe(p: ChildProcess): NodeJS.ReadableStream;
367-
writePipe(p: ChildProcess): NodeJS.WritableStream;
367+
createTransport(p: ChildProcess): ConnectionTransport;
368368
};
369369

370370
function copyTestHooks(from: object, to: object) {

packages/playwright-core/src/server/webkit/webkit.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { BrowserType, kNoXServerRunningError, LaunchLifecycleHooks } from '../br
2525
import { WKBrowser } from '../webkit/wkBrowser';
2626
import { spawnAsync } from '../utils/spawnAsync';
2727
import { registry } from '../registry';
28+
import { PipeTransport } from '../pipeTransport';
2829

2930
import type { BrowserOptions } from '../browser';
3031
import type { SdkObject } from '../instrumentation';
@@ -116,7 +117,7 @@ export class WebKit extends BrowserType {
116117
async amendEnvironment(env, options, userDataDir, isPersistent) {
117118
return {
118119
...env,
119-
'CURL_COOKIE_JAR_PATH': process.platform === 'win32' && isPersistent && options.channel !== 'webkit-wsl' ? path.join(userDataDir, 'cookiejar.db') : undefined,
120+
'CURL_COOKIE_JAR_PATH': process.platform === 'win32' && isPersistent ? path.join(userDataDir, 'cookiejar.db') : undefined,
120121
};
121122
}
122123
};
@@ -146,8 +147,9 @@ export class WebKit extends BrowserType {
146147
'PW_WKWSL_PORT': (transportServer.address() as net.AddressInfo)?.port?.toString() ?? '',
147148
};
148149
},
149-
readPipe: () => readPipe,
150-
writePipe: () => writePipe,
150+
createTransport(p): ConnectionTransport {
151+
return new PipeTransport(writePipe, readPipe);
152+
}
151153
};
152154
}
153155
}

0 commit comments

Comments
 (0)