fix(cli): macOS force exit cuts off the telemetry flush at exit
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- nodejs, typescript
- Lĩnh vực
- cli, observability
Hướng nghiên cứu
The race is between scheduleForceExit() in packages/cli/src/lib/force-exit.ts, armed in the finally of packages/cli/src/cli.ts, and the beforeExit flush in createBeforeExitHandler() in packages/cli/src/lib/telemetry.ts. Start by reproducing on macOS with a metric sent just before exit and tracing when the timer fires relative to client.flush(3000). Done means the flush completes before exit on darwin, the #1237 and #833 protections still hold, and the fix chooses one of the approaches listed in the issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
On macOS, the CLI force-exit backstop can stop the telemetry flush that runs at exit. Data that the SDK has not sent yet is lost.
Cause
- In the
finallyofpackages/cli/src/cli.ts,scheduleForceExit()arms an unref'd 100 ms timer that callsprocess.exit()(packages/cli/src/lib/force-exit.ts). It runs only on darwin. - When the command's work drains,
beforeExitfires.createBeforeExitHandler()inpackages/cli/src/lib/telemetry.tsends the session and startsclient.flush(3000). - The flush opens HTTP requests. These keep the event loop alive, so the unref'd timer can fire.
- The timer calls
process.exit()before the flush completes. The flush is cut off.
The comment at the call site says the timer is a no-op on clean exits. That is true only until beforeExit starts new I/O. After that, the flush itself is the handle that keeps the loop alive.
Impact
Any data still in the SDK buffer when a command ends can be lost on macOS. For example:
- Metrics: the SDK buffers them for up to 5 s, so the exit flush is often the only send.
- Session updates from
Sentry.endSession()in thebeforeExithandler. - Client reports and runtime metrics that are sent at shutdown.
Evidence
The Snake leaderboard (#1437) found this problem. A snake.score metric was lost every time the player quit within about 5 s of game over. A trace log showed that the beforeExit flush started and the process exited before the request completed. #1437 works around this only for the score: it calls client.flush() when the game ends (packages/cli/src/lib/games/score.ts).
I saw the loss only for metrics. The impact on sessions and client reports comes from reading the code. I did not reproduce it.
Possible fixes
- Let the telemetry flush delay the force exit. For example,
beforeExitcould clear or postpone the timer untilflush()settles, with a maximum wait. - Flush telemetry in the
finallyofcli.tsbeforescheduleForceExit(), and keep the existing 3 s limit. - Arm the timer only after the telemetry flush settles.
Any fix must keep the protection from #1237 and #833 against processes that do not exit.
- Ngôn ngữ chính
- TypeScript
- Star
- 938
- Fork
- 166
- Merge trung bình
- 1 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 156
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của getsentry/toolkit
-
bug MCP
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
getsentry/toolkit#1600 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
getsentry/toolkit#1471 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
getsentry/toolkit#1611 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement MCP
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 55/100
getsentry/toolkit#1601 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Use typed detector schemas from @sentry/api for metric monitorsCó thể đã có người làm @MathurAditya724 đã nhận 1 ngày trước. Đang mở
getsentry/toolkit#1595 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của getsentry/toolkit
Issue tương tự
-
[Feature]: 建议导入源后,自动切换到新导入的源Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
lyswhut/lx-music-desktop#3026 ·
-
area: ci type: test
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
schlessera/brain-kit#2769 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Read a vector index's quantization back on Neo4j 2026.10, which reports vector.quantization.typeĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
liberation-data/drivine#231 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
alveusgg/alveusgg#2502 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày