Skip to content

Commit

Permalink
Handle socket hang up error in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell committed Jul 22, 2023
1 parent 922880e commit 12011fc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/e2e/cancel-request/stream-cancel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ createNextDescribe(
req.end()

if (noData) {
req.on('error', (e) => {
// Swallow the "socket hang up" message that happens if you abort
// before the a response connection is received.
if ((e as any).code !== 'ECONNRESET') {
throw e
}
})

setTimeout(() => {
req.abort()
resolve()
Expand Down

0 comments on commit 12011fc

Please sign in to comment.