Skip to content

Commit 95990e7

Browse files
robobunClaude Botclaude
authored
Give us way to know if crashing inside exit handler (oven-sh#21401)
## Summary - Add `exited: usize = 0` field to analytics Features struct - Increment the counter atomically in `Global.exit` when called - Provides visibility into how often exit is being called ## Test plan - [x] Syntax check passes for both modified files - [x] Code compiles without errors 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com>
1 parent f2e487b commit 95990e7

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

src/Global.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ pub fn isExiting() bool {
104104
/// Flushes stdout and stderr (in exit/quick_exit callback) and exits with the given code.
105105
pub fn exit(code: u32) noreturn {
106106
is_exiting.store(true, .monotonic);
107+
_ = @atomicRmw(usize, &bun.analytics.Features.exited, .Add, 1, .monotonic);
107108

108109
// If we are crashing, allow the crash handler to finish it's work.
109110
bun.crash_handler.sleepForeverIfAnotherThreadIsCrashing();

src/analytics.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ pub const Features = struct {
110110
pub var csrf_verify: usize = 0;
111111
pub var csrf_generate: usize = 0;
112112
pub var unsupported_uv_function: usize = 0;
113+
pub var exited: usize = 0;
113114

114115
comptime {
115116
@export(&napi_module_register, .{ .name = "Bun__napi_module_register_count" });

0 commit comments

Comments
 (0)