native-fixes: guard attach against a browser this process already drives (Firefox single BiDi session); report the existing connection instead of stranding it
This commit is contained in:
@@ -982,6 +982,14 @@ async function run(args) {
|
||||
}
|
||||
case 'attach': {
|
||||
const port = effectivePort(args);
|
||||
// Firefox allows exactly one WebDriver BiDi session. Re-attaching to a
|
||||
// browser this process already drives would open a second socket against
|
||||
// that single session, fail the handshake, and strand the browser with no
|
||||
// owner (neither relaunch nor close could reach it). Report the existing
|
||||
// connection instead.
|
||||
if (session && session.port === port && session.ws.readyState === 1) {
|
||||
return { ok: true, attached: true, port, liveMode: !!session.attached, alreadyConnected: true, note: 'already connected to this browser in this process' };
|
||||
}
|
||||
await attachOnly(port);
|
||||
return { ok: true, attached: true, port, liveMode: true };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user