Skip to content

Commit 876c550

Browse files
Fix: Rust Client Disconnect Race (#700)
1 parent e3d46d2 commit 876c550

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/common': patch
3+
---
4+
5+
Fix issue where Rust sync implementation might not disconnect in some circumstances.

packages/common/src/client/sync/stream/AbstractRemote.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,10 @@ export abstract class AbstractRemote {
502502
* Aborting the active fetch request while it is being consumed seems to throw
503503
* an unhandled exception on the window level.
504504
*/
505+
if (abortSignal?.aborted) {
506+
throw new AbortOperation('Abort request received before making postStreamRaw request');
507+
}
508+
505509
const controller = new AbortController();
506510
let requestResolved = false;
507511
abortSignal?.addEventListener('abort', () => {

packages/common/src/client/sync/stream/AbstractStreamingSyncImplementation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,9 @@ The next upload iteration will be delayed.`);
899899
let receivingLines: Promise<void> | null = null;
900900
let hadSyncLine = false;
901901

902+
if (signal.aborted) {
903+
throw new AbortOperation('Connection request has been aborted');
904+
}
902905
const abortController = new AbortController();
903906
signal.addEventListener('abort', () => abortController.abort());
904907

0 commit comments

Comments
 (0)