Skip to content

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

chore: mirror testserver close rejecting callbacks (#38271)

Simon Knott53f146a2cdbc
diff --git a/packages/playwright/src/isomorphic/testServerConnection.ts b/packages/playwright/src/isomorphic/testServerConnection.ts
index 31928563ee..aa4313553e 100644
--- a/packages/playwright/src/isomorphic/testServerConnection.ts
+++ b/packages/playwright/src/isomorphic/testServerConnection.ts
@@ -21,6 +21,12 @@ import type * as reporterTypes from '../../types/testReporter';
// -- Reuse boundary -- Everything below this line is reused in the vscode extension.
+export class TestServerConnectionClosedError extends Error {
+ constructor() {
+ super('Test server connection closed');
+ }
+}
+
export interface TestServerTransport {
onmessage(listener: (message: string) => void): void;
onopen(listener: () => void): void;
@@ -118,6 +124,9 @@ export class TestServerConnection implements TestServerInterface, TestServerInte
this._isClosed = true;
this._onCloseEmitter.fire();
clearInterval(pingInterval);
+ for (const callback of this._callbacks.values())
+ callback.reject(new TestServerConnectionClosedError());
+ this._callbacks.clear();
});
}