Skip to content

Commit

Permalink
Fix Undici abort test to work with 6.12.0 (#93)
Browse files Browse the repository at this point in the history
Test no longer likes being run against a nonexistent server. Was
getting ECONNREFUSED instead of an abort.

Most likely caused by one of the following changes to Undici added in
6.12.0:

nodejs/undici#3053
nodejs/undici#3056
  • Loading branch information
JoshMock authored Apr 11, 2024
1 parent b056c39 commit 403fc67
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"ms": "^2.1.3",
"secure-json-parse": "^2.4.0",
"tslib": "^2.4.0",
"undici": "^6.7.0"
"undici": "^6.12.0"
},
"tap": {
"ts": true,
Expand Down
7 changes: 6 additions & 1 deletion test/unit/undici-connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,12 @@ test('Abort with a slow body', async t => {
t.plan(1)

const controller = new AbortController()
function handler (_req: http.IncomingMessage, res: http.ServerResponse) {
res.end('ok')
}
const [{ port }, server] = await buildServer(handler)
const connection = new UndiciConnection({
url: new URL('https://localhost:9200')
url: new URL(`http://localhost:${port}`)
})

const slowBody = new Readable({
Expand All @@ -540,6 +544,7 @@ test('Abort with a slow body', async t => {
} catch (err: any) {
t.ok(err instanceof RequestAbortedError)
}
server.stop()
})

// The nodejs http agent will try to wait for the whole
Expand Down

0 comments on commit 403fc67

Please sign in to comment.