From 06043c8933c06e32b7c02a63ab6477c32d89539c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCrg=C3=BCn=20Day=C4=B1o=C4=9Flu?= Date: Sun, 5 May 2024 01:15:09 +0200 Subject: [PATCH] Update for Fastify v5 (#69) * update * ci * update workflow * start from 16 * add node 22 * only test on v5 versions --- .github/workflows/ci.yml | 2 +- index.js | 8 ++++---- lib/server.js | 5 ++--- package.json | 16 ++++++++-------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7b00276..7deb9f2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ on: jobs: test: - uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3 + uses: fastify/workflows/.github/workflows/plugins-ci.yml@v4.2.0 with: license-check: true lint: true diff --git a/index.js b/index.js index 26cd9ec..f795882 100644 --- a/index.js +++ b/index.js @@ -35,7 +35,7 @@ async function restartable (factory, opts, fastify = defaultFastify) { restoreClientErrorListeners(server, clientErrorListeners) // In case if fastify.listen() would throw an error - // istanbul ignore next + /* c8 ignore next 3 */ if (newApp !== null) { await closeApplication(newApp) } @@ -74,7 +74,7 @@ async function restartable (factory, opts, fastify = defaultFastify) { function serverFactory (handler, options) { // this cause an uncaughtException because of the bug in Fastify // see: https://github.com/fastify/fastify/issues/4730 - // istanbul ignore next + /* c8 ignore next 6 */ if (++createServerCounter > 1) { throw new Error( 'Cannot create multiple server bindings for a restartable application. ' + @@ -152,14 +152,14 @@ function wrapServer (server) { const _close = server.close.bind(server) server.close = (cb) => server[closingServer] ? _close(cb) : cb() - // istanbul ignore next + /* c8 ignore next 5 */ // closeAllConnections was added in Nodejs v18.2.0 if (server.closeAllConnections) { const _closeAllConnections = server.closeAllConnections.bind(server) server.closeAllConnections = () => server[closingServer] && _closeAllConnections() } - // istanbul ignore next + /* c8 ignore next 5 */ // closeIdleConnections was added in Nodejs v18.2.0 if (server.closeIdleConnections) { const _closeIdleConnections = server.closeIdleConnections.bind(server) diff --git a/lib/server.js b/lib/server.js index 5e7ad01..091b1f0 100644 --- a/lib/server.js +++ b/lib/server.js @@ -36,10 +36,9 @@ function getServerInstance (options, httpHandler) { function http2 () { try { return require('node:http2') - } catch (err) { - // istanbul ignore next + } /* c8 ignore start */ catch (err) { throw new FST_ERR_HTTP2_INVALID_VERSION() - } + } /* c8 ignore end */ } function sessionTimeout (timeout) { diff --git a/package.json b/package.json index e747cdf..234e71c 100644 --- a/package.json +++ b/package.json @@ -29,17 +29,17 @@ }, "homepage": "https://github.com/fastify/restartable#readme", "devDependencies": { - "@fastify/pre-commit": "^2.0.2", - "@types/node": "^20.1.0", + "@fastify/pre-commit": "^2.1.0", + "@types/node": "^20.12.7", "snazzy": "^9.0.0", - "split2": "^4.1.0", - "standard": "^17.0.0-2", - "tap": "^16.0.0", - "tsd": "^0.30.0", - "undici": "^5.0.0" + "split2": "^4.2.0", + "standard": "^17.1.0", + "tap": "^18.7.2", + "tsd": "^0.31.0", + "undici": "^6.13.0" }, "dependencies": { - "fastify": "^4.16.3" + "fastify": "^4.26.2" }, "pre-commit": [ "lint",