Skip to content

Commit

Permalink
Ensure Bare.exit() can be called in idle
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperisager committed Jun 21, 2024
1 parent d19cc73 commit bed9ca3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test/exit-on-idle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* global Bare */
Bare
.on('idle', () => {
Bare.exit()
})
.suspend()

0 comments on commit bed9ca3

Please sign in to comment.