Closed nijikokun closed 1 year ago
You should only have to ctrl-c once for an orderly shutdown, so would guess something is blocking, and then the second ctrl-c does a hard kill which doesn't shutdown cleanly. Can you give the example code?
Absolutely, here is my example code:
const express = require('express')
const ngrok = require('@ngrok/ngrok')
const app = express()
app.get('/', (req, res) => {
res.send('Hello World!')
})
ngrok.listen(app).then(() => {
const url = app.tunnel.url()
console.log("Click to view application: " + url);
})
Adding, I've tried using one CTRL+C and it still occurs, seems like it doesn't matter whether it's one or two.
Shuts down cleanly for me after a single ctrl-c on mac-aarch64 and ubuntu-x86_64, if you've made a request there's a few seconds of delay as things are torn down. What os and architecture are you on?
What architecture
MacOS M2, 13.0 (22A380)
Running VSCode
Running through npm via npm run start
After retrying without npm looks like it's isolated to npm run
usage.
Turns out npm double-taps SIGINT to the underlying process, so the handler code is executed twice in very quick succession, will add protections around this.
Updated in https://github.com/ngrok/ngrok-js/pull/51, released in 0.4.1
Confirmed working with 0.4.1
➜ ngrok-js-demo npm run start
> ngrok-js-demo@1.0.0 start
> node index.js
Click to view application: https://7226-107-132-213-237.ngrok.io
^C%
➜ ngrok-js-demo
👍
Using basic hello-world express application, when closing the socket via CTRL+C (twice) I get the following error output: