Skip to content

Commit

Permalink
fix: When closing socket destroy() instead of end() it (#967)
Browse files Browse the repository at this point in the history
  • Loading branch information
zobo committed Jul 15, 2024
1 parent a4f92b9 commit 9043033
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,12 @@ class InnerCloudTransport extends EventEmitter implements Transport {
}
return this
}

destroy(error?: Error): this {
if (this._open) {
this._open = false
this.emit('close')
}
return this
}
}
3 changes: 2 additions & 1 deletion src/dbgp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface Transport {
on(event: 'close', listener: () => void): this
write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean
end(callback?: () => void): this
destroy(error?: Error): this
}

export declare interface DbgpConnection {
Expand Down Expand Up @@ -145,7 +146,7 @@ export class DbgpConnection extends EventEmitter {

/** closes the underlying socket */
public close(): Promise<void> {
this._socket.end()
this._socket.destroy()
return this._closePromise
}
}

0 comments on commit 9043033

Please sign in to comment.