Skip to content

Commit

Permalink
fix: cleanup requests when resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Nov 27, 2018
1 parent 997a268 commit 57ff010
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/comms/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,7 @@ export default abstract class Client {
const resolve = this.requests[responseObj.id]
if (!resolve) throw new Error(`No request found for response with id: ${responseObj.id}`)
resolve(responseObj)
// Clean up by deleting the request entry
delete this.requests[responseObj.id]
}
}
3 changes: 3 additions & 0 deletions tests/comms/StdioClient.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,7 @@ test('StdioClient', async () => {
expect(error.message).toEqual("Internal error: Unhandled import format: bar/baz")
}
}

// There should be no more requests waiting for a response
expect(Object.keys(client.requests).length).toEqual(0)
})

0 comments on commit 57ff010

Please sign in to comment.