mirror of https://github.com/garrytan/gstack.git
fix(browse): guard browser.process() in resolveDisconnectCause
`.process()` only exists on browsers Playwright launched itself; a browser from connectOverCDP() (or a test stub) has no such method, so the blind call threw "browser?.process is not a function" inside the disconnect handler and took down the daemon. Type-check the method before calling it and treat the no-method case as no process handle. Closes #2085. Contributed by @elan2002 (PR #2434). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
0350b2d758
commit
865eaf6f2b
|
|
@ -91,7 +91,11 @@ export function shouldEnableChromiumSandbox(): boolean {
|
|||
* restarts on backoff.
|
||||
*/
|
||||
export async function resolveDisconnectCause(browser: Browser | null): Promise<'clean' | 'crash'> {
|
||||
const proc = browser?.process();
|
||||
// `.process()` only exists on browsers we launched ourselves. A browser
|
||||
// obtained via connectOverCDP() (or a stub in tests) has no such method —
|
||||
// calling it blind throws inside the disconnect handler, which killed the
|
||||
// whole daemon with "browser?.process is not a function".
|
||||
const proc = typeof browser?.process === 'function' ? browser.process() : null;
|
||||
if (proc && proc.exitCode === null && proc.signalCode === null) {
|
||||
await new Promise<void>((resolve) => {
|
||||
const timer = setTimeout(resolve, 1000);
|
||||
|
|
|
|||
Loading…
Reference in New Issue