File tree Expand file tree Collapse file tree 3 files changed +10
-3
lines changed
common/src/client/sync/stream Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -449,15 +449,16 @@ The next upload iteration will be delayed.`);
449449 await this . streamingSyncIteration ( nestedAbortController . signal , options ) ;
450450 // Continue immediately, streamingSyncIteration will wait before completing if necessary.
451451 } catch ( ex ) {
452- let delay = true ;
453452 /**
454453 * Either:
455454 * - A network request failed with a failed connection or not OKAY response code.
456455 * - There was a sync processing error.
457- * This loop will retry.
456+ * - The connection was aborted.
457+ * This loop will retry after a delay if the connection was not aborted.
458458 * The nested abort controller will cleanup any open network requests and streams.
459459 * The WebRemote should only abort pending fetch requests or close active Readable streams.
460460 */
461+ let delay = true ;
461462 if ( ex instanceof AbortOperation ) {
462463 this . logger . warn ( ex ) ;
463464 delay = false ;
Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ export class SharedSyncImplementation
145145 await this . openInternalDB ( ) ;
146146 }
147147
148- const sync = await this . generateStreamingImplementation ( ) ;
148+ const sync = this . generateStreamingImplementation ( ) ;
149149 const onDispose = sync . registerListener ( {
150150 statusChanged : ( status ) => {
151151 this . updateAllStatuses ( status . toJSON ( ) ) ;
@@ -270,6 +270,9 @@ export class SharedSyncImplementation
270270 * clients.
271271 */
272272 async removePort ( port : MessagePort ) {
273+ // Remove the port within a mutex context.
274+ // Warns if the port is not found. This should not happen in practice.
275+ // We return early if the port is not found.
273276 const { trackedPort, shouldReconnect } = await this . portMutex . runExclusive ( async ( ) => {
274277 const index = this . ports . findIndex ( ( p ) => p . port == port ) ;
275278 if ( index < 0 ) {
Original file line number Diff line number Diff line change @@ -81,6 +81,9 @@ export class MockRemote extends AbstractRemote {
8181 if ( this . errorOnStreamStart ) {
8282 controller . error ( new Error ( 'Mock error on stream start' ) ) ;
8383 }
84+ // The request could be aborted at any time.
85+ // This checks if the signal is already aborted and closes the stream if so.
86+ // If not, it adds an event listener to close the stream when the signal is aborted.
8487 if ( signal ?. aborted ) {
8588 controller . close ( ) ;
8689 return ;
You can’t perform that action at this time.
0 commit comments