Skip to content

Commit 9043033

Browse files
committed
fix: When closing socket destroy() instead of end() it (#967)
1 parent a4f92b9 commit 9043033

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/cloud.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,12 @@ class InnerCloudTransport extends EventEmitter implements Transport {
225225
}
226226
return this
227227
}
228+
229+
destroy(error?: Error): this {
230+
if (this._open) {
231+
this._open = false
232+
this.emit('close')
233+
}
234+
return this
235+
}
228236
}

src/dbgp.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface Transport {
1818
on(event: 'close', listener: () => void): this
1919
write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean
2020
end(callback?: () => void): this
21+
destroy(error?: Error): this
2122
}
2223

2324
export declare interface DbgpConnection {
@@ -145,7 +146,7 @@ export class DbgpConnection extends EventEmitter {
145146

146147
/** closes the underlying socket */
147148
public close(): Promise<void> {
148-
this._socket.end()
149+
this._socket.destroy()
149150
return this._closePromise
150151
}
151152
}

0 commit comments

Comments
 (0)