Skip to content

Commit b1e56bf

Browse files
Fix closure of libsignal socket on reconnect
1 parent d456077 commit b1e56bf

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

ts/textsecure/WebsocketResources.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,10 @@ function connectLibsignal(
443443
logId,
444444
keepalive
445445
);
446+
if (abortController.signal.aborted) {
447+
resource.close(3000, 'aborted');
448+
throw new Error('Aborted');
449+
}
446450
// eslint-disable-next-line no-param-reassign
447451
resourceHolder.resource = resource;
448452
return resource;
@@ -454,7 +458,16 @@ function connectLibsignal(
454458
};
455459
return new AbortableProcess<LibsignalWebSocketResource>(
456460
`${logId}.connect`,
457-
abortController,
461+
{
462+
abort() {
463+
if (resourceHolder.resource != null) {
464+
log.warn(`${logId}: closing socket`);
465+
resourceHolder.resource.close(3000, 'aborted');
466+
} else {
467+
abortController.abort();
468+
}
469+
},
470+
},
458471
connectAsync()
459472
);
460473
}

0 commit comments

Comments
 (0)