diff --git a/src/runtime.c b/src/runtime.c index 1bfa9e2..ef4f90a 100644 --- a/src/runtime.c +++ b/src/runtime.c @@ -1168,7 +1168,9 @@ bare_runtime_run (bare_runtime_t *runtime) { if (uv_loop_alive(runtime->loop)) continue; - uv_ref((uv_handle_t *) &runtime->signals.resume); + if (!runtime->terminated) { + uv_ref((uv_handle_t *) &runtime->signals.resume); + } } else { bare_runtime_on_before_exit(runtime); } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a16c1a3..b4c6745 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,6 +3,7 @@ list(APPEND tests addon-resolve.js argv-empty.c exit-on-before-exit.js + exit-on-idle.js import-addon.cjs import-addon.mjs import-bundle.js diff --git a/test/exit-on-idle.js b/test/exit-on-idle.js new file mode 100644 index 0000000..85021c2 --- /dev/null +++ b/test/exit-on-idle.js @@ -0,0 +1,6 @@ +/* global Bare */ +Bare + .on('idle', () => { + Bare.exit() + }) + .suspend()