Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).

- fix: reject create conflicts and duplicate permission targets
- fix(sql): seed ns export types coredns & native for 2.x upgrade
- fix: server stop waits for the stores to disconnect

### [3.0.3] - 2026-07-27

Expand Down
2 changes: 1 addition & 1 deletion routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
},
httpAuthScheme: 'Bearer',
headerName: 'authorization',
validate: (artifacts, request, h) => {

Check warning on line 99 in routes/index.js

View workflow job for this annotation

GitHub Actions / lint / lint

'h' is defined but never used

Check warning on line 99 in routes/index.js

View workflow job for this annotation

GitHub Actions / lint / lint

'request' is defined but never used
return {
isValid: true,
credentials: artifacts.decoded.payload.nt,
Expand Down Expand Up @@ -155,7 +155,7 @@
}
})

server.events.on('stop', async () => {
server.ext('onPostStop', async () => {
await User.disconnect()
await Session.disconnect()
})
Expand Down
34 changes: 34 additions & 0 deletions routes/lifecycle.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import assert from 'node:assert/strict'
import { test } from 'node:test'

import User from '../lib/user/index.js'
import { init } from './index.js'

test('server stop waits for store disconnection', async (t) => {
const server = await init()
let enterDisconnect
let releaseDisconnect
const entered = new Promise((resolve) => {
enterDisconnect = resolve
})
const released = new Promise((resolve) => {
releaseDisconnect = resolve
})

t.mock.method(User, 'disconnect', async () => {
enterDisconnect()
await released
})

let stopped = false
const stopping = server.stop().then(() => {
stopped = true
})
await entered
await new Promise((resolve) => setImmediate(resolve))
assert.equal(stopped, false)

releaseDisconnect()
await stopping
assert.equal(stopped, true)
})
Loading