Skip to content

Commit 03ea432

Browse files
committed
Merge branch 'process-signals' into master
2 parents fd9e6d1 + 592e5d4 commit 03ea432

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/process.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ async function startProcess(opts) {
8888
activeProcess = null;
8989
});
9090

91-
process.on("exit", async () => await killProcess());
92-
9391
try {
9492
const url = await apiUrl;
9593
activeProcess = ngrok;
@@ -107,13 +105,21 @@ async function startProcess(opts) {
107105
}
108106

109107
function killProcess() {
110-
if (!activeProcess) return;
108+
if (!activeProcess) {
109+
return Promise.resolve();
110+
}
111111
return new Promise((resolve) => {
112112
activeProcess.on("exit", () => resolve());
113113
activeProcess.kill();
114114
});
115115
}
116116

117+
process.on("exit", () => {
118+
if (activeProcess) {
119+
activeProcess.kill();
120+
}
121+
});
122+
117123
/**
118124
* @param {string | Ngrok.Options} optsOrToken
119125
*/

0 commit comments

Comments
 (0)