mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-15 14:11:50 +03:00
fix: catch websocket error events (#1595)
This commit is contained in:
parent
eabba567bc
commit
950d427927
@ -18,7 +18,7 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { helper } from '../helper';
|
import { debugError, helper } from '../helper';
|
||||||
import { CRBrowser } from '../chromium/crBrowser';
|
import { CRBrowser } from '../chromium/crBrowser';
|
||||||
import * as platform from '../platform';
|
import * as platform from '../platform';
|
||||||
import * as ws from 'ws';
|
import * as ws from 'ws';
|
||||||
@ -269,6 +269,8 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, port: number
|
|||||||
session.queue!.push(parsedMessage);
|
session.queue!.push(parsedMessage);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('error', error => debugError(error));
|
||||||
|
|
||||||
socket.on('close', (socket as any).__closeListener = () => {
|
socket.on('close', (socket as any).__closeListener = () => {
|
||||||
const session = socketToBrowserSession.get(socket);
|
const session = socketToBrowserSession.get(socket);
|
||||||
if (!session || !session.sessionId)
|
if (!session || !session.sessionId)
|
||||||
|
@ -25,7 +25,7 @@ import { TimeoutError } from '../errors';
|
|||||||
import { Events } from '../events';
|
import { Events } from '../events';
|
||||||
import { FFBrowser } from '../firefox/ffBrowser';
|
import { FFBrowser } from '../firefox/ffBrowser';
|
||||||
import { kBrowserCloseMessageId } from '../firefox/ffConnection';
|
import { kBrowserCloseMessageId } from '../firefox/ffConnection';
|
||||||
import { helper } from '../helper';
|
import { debugError, helper } from '../helper';
|
||||||
import * as platform from '../platform';
|
import * as platform from '../platform';
|
||||||
import { BrowserServer, WebSocketWrapper } from './browserServer';
|
import { BrowserServer, WebSocketWrapper } from './browserServer';
|
||||||
import { BrowserArgOptions, BrowserType, LaunchOptions } from './browserType';
|
import { BrowserArgOptions, BrowserType, LaunchOptions } from './browserType';
|
||||||
@ -297,6 +297,8 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, port: number
|
|||||||
pendingBrowserContextDeletions.set(seqNum, params.browserContextId);
|
pendingBrowserContextDeletions.set(seqNum, params.browserContextId);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('error', error => debugError(error));
|
||||||
|
|
||||||
socket.on('close', (socket as any).__closeListener = () => {
|
socket.on('close', (socket as any).__closeListener = () => {
|
||||||
for (const [browserContextId, s] of browserContextIds) {
|
for (const [browserContextId, s] of browserContextIds) {
|
||||||
if (s === socket) {
|
if (s === socket) {
|
||||||
|
@ -22,7 +22,7 @@ import * as fs from 'fs';
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as platform from '../platform';
|
import * as platform from '../platform';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import { helper } from '../helper';
|
import { debugError, helper } from '../helper';
|
||||||
import { kBrowserCloseMessageId } from '../webkit/wkConnection';
|
import { kBrowserCloseMessageId } from '../webkit/wkConnection';
|
||||||
import { LaunchOptions, BrowserArgOptions, BrowserType } from './browserType';
|
import { LaunchOptions, BrowserArgOptions, BrowserType } from './browserType';
|
||||||
import { ConnectionTransport, SequenceNumberMixer } from '../transport';
|
import { ConnectionTransport, SequenceNumberMixer } from '../transport';
|
||||||
@ -276,6 +276,8 @@ function wrapTransportWithWebSocket(transport: ConnectionTransport, port: number
|
|||||||
pendingBrowserContextDeletions.set(seqNum, params.browserContextId);
|
pendingBrowserContextDeletions.set(seqNum, params.browserContextId);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('error', error => debugError(error));
|
||||||
|
|
||||||
socket.on('close', (socket as any).__closeListener = () => {
|
socket.on('close', (socket as any).__closeListener = () => {
|
||||||
for (const [pageProxyId, s] of pageProxyIds) {
|
for (const [pageProxyId, s] of pageProxyIds) {
|
||||||
if (s === socket)
|
if (s === socket)
|
||||||
|
Loading…
Reference in New Issue
Block a user