@@ -719,22 +719,25 @@ export class RemoteStore implements TargetMetadataProvider {
719
719
'Write stream was stopped gracefully while still needed.'
720
720
) ;
721
721
}
722
- // An error that occurs after the write handshake completes is an indication
723
- // that the write operation itself failed.
724
- if ( error && this . writeStream . handshakeComplete ) {
725
- // This error affects the actual write.
726
- await this . handleWriteError ( error ! ) ;
727
- } else if ( error ) {
728
- // If there was an error before the handshake has finished, it's
729
- // possible that the server is unable to process the stream token
730
- // we're sending. (Perhaps it's too old?)
731
- await this . handleHandshakeError ( error ! ) ;
732
- }
733
722
734
- // The write stream might have been started by refilling the write
735
- // pipeline for failed writes
736
- if ( this . shouldStartWriteStream ( ) ) {
737
- this . startWriteStream ( ) ;
723
+ // If the write stream closed due to an error, invoke the error callbacks if
724
+ // there are pending writes.
725
+ if ( error && this . writePipeline . length > 0 ) {
726
+ if ( this . writeStream . handshakeComplete ) {
727
+ // This error affects the actual write.
728
+ await this . handleWriteError ( error ! ) ;
729
+ } else {
730
+ // If there was an error before the handshake has finished, it's
731
+ // possible that the server is unable to process the stream token
732
+ // we're sending. (Perhaps it's too old?)
733
+ await this . handleHandshakeError ( error ! ) ;
734
+ }
735
+
736
+ // The write stream might have been started by refilling the write
737
+ // pipeline for failed writes
738
+ if ( this . shouldStartWriteStream ( ) ) {
739
+ this . startWriteStream ( ) ;
740
+ }
738
741
}
739
742
// No pending writes, nothing to do
740
743
}
0 commit comments