@@ -136,13 +136,15 @@ export class YamuxStream implements Stream {
136
136
throw new Error ( 'stream closed for writing' )
137
137
}
138
138
139
- source = abortableSource ( source , anySignal ( [
139
+ const signal = anySignal ( [
140
140
this . abortController . signal ,
141
141
this . resetController . signal ,
142
142
this . closeController . signal
143
- ] ) , { returnOnAbort : true } )
143
+ ] )
144
144
145
145
try {
146
+ source = abortableSource ( source , signal )
147
+
146
148
for await ( let data of source ) {
147
149
// send in chunks, waiting for window updates
148
150
while ( data . length !== 0 ) {
@@ -157,16 +159,22 @@ export class YamuxStream implements Stream {
157
159
}
158
160
}
159
161
} catch ( e : any ) {
162
+ if ( this . closeController . signal . aborted ) {
163
+ return
164
+ }
165
+
160
166
if ( this . resetController . signal . aborted ) {
161
167
this . reset ( )
162
168
}
163
169
170
+ if ( this . abortController . signal . aborted ) {
171
+ this . abort ( )
172
+ }
173
+
164
174
if ( e . code === ERR_STREAM_RESET ) {
165
175
this . reset ( )
166
176
this . log ?. trace ( '%s stream %s reset' )
167
177
}
168
-
169
- this . log ?. error ( 'stream sink error id=%s' , this . _id , e )
170
178
} finally {
171
179
this . log ?. trace ( 'stream sink ended id=%s' , this . _id )
172
180
this . closeWrite ( )
@@ -218,6 +226,10 @@ export class YamuxStream implements Stream {
218
226
}
219
227
220
228
closeWrite ( ) : void {
229
+ this . log ?. trace ( 'stream close write id=%s' , this . _id )
230
+
231
+ this . closeController . abort ( )
232
+
221
233
if ( this . state === StreamState . Finished ) {
222
234
return
223
235
}
@@ -226,8 +238,6 @@ export class YamuxStream implements Stream {
226
238
return
227
239
}
228
240
229
- this . log ?. trace ( 'stream close write id=%s' , this . _id )
230
-
231
241
this . writeState = HalfStreamState . Closed
232
242
233
243
this . sendClose ( )
0 commit comments