Skip to content
This repository has been archived by the owner on May 5, 2022. It is now read-only.

Commit

Permalink
fix: server shutdown hangs if no client address
Browse files Browse the repository at this point in the history
If the client never shared their ILP address and server.close() is called or the connection is closed from the server, the Promise would never resolve/send loop would never exit
  • Loading branch information
kincaidoneil committed Jun 3, 2020
1 parent 4b42005 commit 7046de8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@ export class Connection extends EventEmitter {
}
if (!this._destinationAccount) {
this.log.debug('not sending because we do not know the client\'s address')
this.safeEmit('_send_loop_finished')
return
}

Expand Down
5 changes: 5 additions & 0 deletions test/connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ describe('Connection', function () {
assert.calledOnce(closeSpy)
})

it('should resolve even if the remote address is unknown', async function () {
delete this.serverConn._destinationAccount
await this.serverConn.end()
})

it('should close all outgoing streams', async function () {
const clientSpy = {
stream1: {
Expand Down

0 comments on commit 7046de8

Please sign in to comment.