Skip to content

Commit

Permalink
Upgrade Undici to v6.7.0 (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
cosieLq authored Apr 2, 2024
1 parent f7c8092 commit 8856e62
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
},
"homepage": "https://github.com/elastic/elastic-transport-js#readme",
"engines": {
"node": ">=16"
"node": ">=18"
},
"devDependencies": {
"@sinonjs/fake-timers": "github:sinonjs/fake-timers#0bfffc1",
"@types/debug": "^4.1.7",
"@types/ms": "^0.7.31",
"@types/node": "^17.0.31",
"@types/node": "^18.19.21",
"@types/sinonjs__fake-timers": "^8.1.2",
"@types/stoppable": "^1.1.1",
"@types/tap": "^15.0.7",
Expand All @@ -64,7 +64,7 @@
"ms": "^2.1.3",
"secure-json-parse": "^2.4.0",
"tslib": "^2.4.0",
"undici": "^5.22.1"
"undici": "^6.7.0"
},
"tap": {
"ts": true,
Expand Down
2 changes: 1 addition & 1 deletion src/connection/UndiciConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ export default class Connection extends BaseConnection {
timeoutId = setTimeout(() => {
timedout = true
if (options.signal != null) {
// @ts-expect-error Event is a Node.js global
options.signal.dispatchEvent(new Event('abort'))
} else {
this[kEmitter].emit('abort')
Expand All @@ -165,6 +164,7 @@ export default class Connection extends BaseConnection {
if (timeoutId != null) clearTimeout(timeoutId)
switch (err.code) {
case 'UND_ERR_ABORTED':
case DOMException.ABORT_ERR:
throw (timedout ? new TimeoutError('Request timed out') : new RequestAbortedError('Request aborted'))
case 'UND_ERR_HEADERS_TIMEOUT':
throw new TimeoutError('Request timed out')
Expand Down
2 changes: 1 addition & 1 deletion test/unit/http-connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ test('Cleanup abort listener', async t => {
method: 'GET',
}, {
...options,
signal: controller.signal
signal: controller.signal as AbortSignal
})
// @ts-expect-error
t.equal(controller.signal.eventEmitter.listeners('abort').length, 0)
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"importHelpers": true,
"outDir": "lib",
"lib": [
"esnext"
"esnext",
"dom"
]
},
"formatCodeOptions": {
Expand Down

0 comments on commit 8856e62

Please sign in to comment.