fix: catch websocket error events (#1595)

This commit is contained in:
Andrey Lushnikov 2020-03-30 18:18:38 -07:00 committed by GitHub
parent eabba567bc
commit 950d427927
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View File

@ -18,7 +18,7 @@
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import { helper } from '../helper';
import { debugError, helper } from '../helper';
import { CRBrowser } from '../chromium/crBrowser';
import * as platform from '../platform';
import * as ws from 'ws';
@ -269,6 +269,8 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, port: number
session.queue!.push(parsedMessage);
});
socket.on('error', error => debugError(error));
socket.on('close', (socket as any).__closeListener = () => {
const session = socketToBrowserSession.get(socket);
if (!session || !session.sessionId)

View File

@ -25,7 +25,7 @@ import { TimeoutError } from '../errors';
import { Events } from '../events';
import { FFBrowser } from '../firefox/ffBrowser';
import { kBrowserCloseMessageId } from '../firefox/ffConnection';
import { helper } from '../helper';
import { debugError, helper } from '../helper';
import * as platform from '../platform';
import { BrowserServer, WebSocketWrapper } from './browserServer';
import { BrowserArgOptions, BrowserType, LaunchOptions } from './browserType';
@ -297,6 +297,8 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, port: number
pendingBrowserContextDeletions.set(seqNum, params.browserContextId);
});
socket.on('error', error => debugError(error));
socket.on('close', (socket as any).__closeListener = () => {
for (const [browserContextId, s] of browserContextIds) {
if (s === socket) {

View File

@ -22,7 +22,7 @@ import * as fs from 'fs';
import * as path from 'path';
import * as platform from '../platform';
import * as os from 'os';
import { helper } from '../helper';
import { debugError, helper } from '../helper';
import { kBrowserCloseMessageId } from '../webkit/wkConnection';
import { LaunchOptions, BrowserArgOptions, BrowserType } from './browserType';
import { ConnectionTransport, SequenceNumberMixer } from '../transport';
@ -276,6 +276,8 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, port: number
pendingBrowserContextDeletions.set(seqNum, params.browserContextId);
});
socket.on('error', error => debugError(error));
socket.on('close', (socket as any).__closeListener = () => {
for (const [pageProxyId, s] of pageProxyIds) {
if (s === socket)