Skip to content

Commit

Permalink
fix: catch websocket error events (#1595)
Browse files Browse the repository at this point in the history
  • Loading branch information
aslushnikov committed Mar 31, 2020
1 parent eabba56 commit 950d427
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/server/chromium.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/server/firefox.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion src/server/webkit.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 950d427

Please sign in to comment.