Skip to content

Commit

Permalink
Update for Fastify v5 (#69)
Browse files Browse the repository at this point in the history
* update

* ci

* update workflow

* start from 16

* add node 22

* only test on v5 versions
  • Loading branch information
gurgunday authored May 4, 2024
1 parent a318614 commit 06043c8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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. ' +
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 06043c8

Please sign in to comment.