Skip to content

Commit

Permalink
Fix receiving HTTP during shutting down
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Aug 27, 2024
1 parent 234f11f commit 5dfd9cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions base-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ export class BaseServer {
if (this.destroying) {
res.writeHead(503, { 'Content-Type': 'text/plain' })
res.end('The server is shutting down\n')
return
}

let urlString = req.url
Expand Down
4 changes: 4 additions & 0 deletions base-server/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1712,6 +1712,10 @@ it('waits until all HTTP processing ends', async () => {
await setTimeout(100)
expect(destroyed).toBe(false)

expect((await requestError(app, 'POST', '/a')).message).toEqual(
'The server is shutting down\n'
)

resolveA!()
await setTimeout(100)
expect(destroyed).toBe(false)
Expand Down

0 comments on commit 5dfd9cd

Please sign in to comment.