@@ -151,19 +151,6 @@ export class MessageStream extends PassThrough {
151151 ) ;
152152 this . _keepAliveHandle . unref ( ) ;
153153 }
154- /**
155- * Destroys the stream and any underlying streams.
156- *
157- * @param {error? } error An error to emit, if any.
158- * @private
159- */
160- destroy ( error ?: Error | null ) : void {
161- // We can't assume Node has taken care of this in <14.
162- if ( this . destroyed ) {
163- return ;
164- }
165- super . destroy ( error ? error : undefined ) ;
166- }
167154 /**
168155 * Destroys the stream and any underlying streams.
169156 *
@@ -172,7 +159,6 @@ export class MessageStream extends PassThrough {
172159 * @private
173160 */
174161 _destroy ( error : Error | null , callback : ( error : Error | null ) => void ) : void {
175- this . destroyed = true ;
176162 clearInterval ( this . _keepAliveHandle ) ;
177163
178164 for ( const stream of this . _streams . keys ( ) ) {
@@ -214,7 +200,8 @@ export class MessageStream extends PassThrough {
214200 try {
215201 client = await this . _getClient ( ) ;
216202 } catch ( e ) {
217- this . destroy ( e ) ;
203+ const err = e as Error ;
204+ this . destroy ( err ) ;
218205 }
219206
220207 if ( this . destroyed ) {
@@ -244,7 +231,8 @@ export class MessageStream extends PassThrough {
244231 try {
245232 await this . _waitForClientReady ( client ) ;
246233 } catch ( e ) {
247- this . destroy ( e ) ;
234+ const err = e as Error ;
235+ this . destroy ( err ) ;
248236 }
249237 }
250238 /**
@@ -386,7 +374,8 @@ export class MessageStream extends PassThrough {
386374 try {
387375 await promisify ( client . waitForReady ) . call ( client , deadline ) ;
388376 } catch ( e ) {
389- throw new ChannelError ( e ) ;
377+ const err = e as Error ;
378+ throw new ChannelError ( err ) ;
390379 }
391380 }
392381}
0 commit comments