Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(platform): properly handle websocket error events (#967)

Andrey Lushnikovd26f47bb3b2e
diff --git a/src/platform.ts b/src/platform.ts
index 6f935b1c24..b4c0fea7ba 100644
--- a/src/platform.ts
+++ b/src/platform.ts
@@ -325,7 +325,7 @@ export class WebSocketTransport implements ConnectionTransport {
}) : new WebSocket(url)) as WebSocket;
this._connect = new Promise((fulfill, reject) => {
this._ws.addEventListener('open', () => fulfill());
- this._ws.addEventListener('error', event => reject(new Error(event.toString())));
+ this._ws.addEventListener('error', event => reject(new Error('WebSocket error: ' + (event as ErrorEvent).message)));
});
// The 'ws' module in node sometimes sends us multiple messages in a single task.
// In Web, all IO callbacks (e.g. WebSocket callbacks)