diff --git a/package.json b/package.json index d9e5c68..03c95a5 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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, diff --git a/src/connection/UndiciConnection.ts b/src/connection/UndiciConnection.ts index af1a825..412f39a 100644 --- a/src/connection/UndiciConnection.ts +++ b/src/connection/UndiciConnection.ts @@ -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') @@ -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') diff --git a/test/unit/http-connection.test.ts b/test/unit/http-connection.test.ts index d2ce5d8..149cb12 100644 --- a/test/unit/http-connection.test.ts +++ b/test/unit/http-connection.test.ts @@ -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) diff --git a/tsconfig.json b/tsconfig.json index e93828b..ea6ec4d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,7 +21,8 @@ "importHelpers": true, "outDir": "lib", "lib": [ - "esnext" + "esnext", + "dom" ] }, "formatCodeOptions": {