Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: catch websocket error events #1595

Merged
merged 1 commit into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/server/chromium.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 } from './browserServer';
import { BrowserArgOptions, BrowserType, LaunchOptions } from './browserType';
Expand Down Expand Up @@ -295,6 +295,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
Original file line number Diff line number Diff line change
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