Closed ringo360 closed 2 weeks ago
Hi @ringo360
I've tried your code. Below is the behavior on my machine.
https://github.com/honojs/hono/assets/10682/1c1f938b-d03e-4824-bfca-215cef8f4a0d
I think this is expected behavior. If you still have a problem, could you provide a minimal project to reproduce it?
Ok, I'll prepare a minimum project.
I think this is not a problem of hono
Sample repo https://github.com/EdamAme-x/hono-issue-3104
I created repo https://github.com/ringo360/hono-i3104/
@ringo360 Thanks!
I've tried it, and it will throw status code 130
since I typed Ctrl+C.
https://github.com/honojs/hono/assets/10682/ac7c9b35-719f-4c9e-bf73-e93352832c75
So, the behavior may change depending on the environment. We have to figure out if it's Hono matter or not. Can you try some cases like it without Hono?
import consola from 'consola'
import color from 'picocolors'
import { config } from './utils/CLoader'
import { onShutdown } from './utils/Scheduler'
import http from 'http'
const server = http.createServer((_req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' })
res.end('Hello Node.js!')
})
server.listen(config.web.port, () => {
consola.info(color.green(`[WebSV] Web Server is ready on port ${color.cyan(config.web.port.toString())}`))
})
onShutdown(() => {
consola.info(color.cyan('[WebSV] Called shutdown event'))
server.close(() => {
consola.info(color.red('[WebSV] Closed web server'))
})
})
Sorry, this seems to be a problem in another area.
It threw status code 1
when I typed Ctrl+C.
https://github.com/honojs/hono/assets/105296365/280b2b90-ad9a-456d-ad0a-664be15cfcfa
@ringo360
So, is not the issue on the Hono side?
@yusukebe Probably yes, may I close this issue?
@ringo360
Okay! I'll close this issue. If you have any problem, feel free to reopen it.
tysm <3
What version of Hono are you using?
4.4.11
What runtime/platform is your app running on?
Node.js
What steps can reproduce the bug?
const closeListeners: any = [];
export async function shutdown() { consola.start(color.italic('Shutting down...')); try { await Promise.race([ Promise.all(closeListeners.map((closeListener: any) => closeListener())), setTimeout(5000), ]); } catch (e) { console.error(e); } consola.success(color.italic('Goodbye!')); process.exit(0); }
process.on('SIGINT', shutdown); process.on('SIGTERM', shutdown);
/**
What is the expected behavior?
The program should have terminated with code 0 and a graceful shutdown should have been achieved.
What do you see instead?
You can confirm that the code is not terminating as expected:![Terminal(VSCode)](https://github.com/honojs/hono/assets/105296365/aa78c2bf-f35c-4a51-8e70-e296de0d9f60)
Additional information
No response