Skip to content

Commit

Permalink
fix: always use destroy instead of end
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Feb 16, 2022
1 parent c23935e commit 212192a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/__mocks__/net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class Socket extends EventEmitter {
this.onWrite(buff, encoding)
}
}
public end(): void {
public destroy(): void {
this.setEnd()
this.setClosed()
}
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/hyperdeck.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('Hyperdeck', () => {
expect(onConnection).toHaveBeenCalledTimes(1)
expect(onDisconnection).toHaveBeenCalledTimes(0)

thisSocket?.end()
thisSocket?.destroy()
await waitALittleBit()

expect(hp.connected).toBeFalsy()
Expand Down
4 changes: 2 additions & 2 deletions src/hyperdeck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export class Hyperdeck extends EventEmitter {
})
.catch((e) => {
this._connected = false
this.socket.end()
this.socket.destroy()
this.emit('error', 'connection failed', e)
this._log('connection failed', e)

Expand Down Expand Up @@ -259,7 +259,7 @@ export class Hyperdeck extends EventEmitter {
} catch (e) {
this._log('socket write failed', e)
try {
this.socket.end()
this.socket.destroy()
} catch (e2) {
// ignore
}
Expand Down

0 comments on commit 212192a

Please sign in to comment.