Skip to content

Commit 3b1fb7d

Browse files
committed
Fix bug where stop()+start() in admin client could trigger reconnects
This didn't actually break normal behaviour, but resulted in a bunch of failing background reconnections for 10s or so, which did block process exit if it happened at the end of a test suite, for example.
1 parent 1651678 commit 3b1fb7d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/client/admin-client.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,12 @@ export class AdminClient<Plugins extends { [key: string]: AdminPlugin<any, any>
269269
// If never connected successfully, we do nothing.
270270
});
271271

272-
targetStream.on('finish', () => { // Client has shutdown
272+
targetStream.on('end', () => { // Client has shutdown
273273
// Ignore any further WebSocket events - the websocket stream is no longer useful
274274
wsStream.removeAllListeners('connect');
275275
wsStream.removeAllListeners('ws-close');
276276
wsStream.destroy();
277+
streamConnected = false;
277278
});
278279

279280
return wsStream;
@@ -291,6 +292,9 @@ export class AdminClient<Plugins extends { [key: string]: AdminPlugin<any, any>
291292
) {
292293
this.emit('stream-reconnecting');
293294

295+
// If the client stops running, stop retrying:
296+
if (!(await this.running)) return;
297+
294298
// Unclean shutdown means something has gone wrong somewhere. Try to reconnect.
295299
const newStream = this.attachStreamWebsocket(adminSessionBaseUrl, targetStream);
296300

0 commit comments

Comments
 (0)