fix(cli): macOS force exit cuts off the telemetry flush at exit
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- nodejs, typescript
- Ambito
- cli, observability
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 938
- Fork
- 166
- Merge medio
- 1g 7h
- PR unite (30g)
- 156
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di getsentry/toolkit
-
bug MCP
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
getsentry/toolkit#1600 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
getsentry/toolkit#1471 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
getsentry/toolkit#1611 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement MCP
Difficoltà 4/5 1-2 giorni Idoneità per principianti 55/100
getsentry/toolkit#1601 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Use typed detector schemas from @sentry/api for metric monitorsForse già presa @MathurAditya724 l’ha presa 1 giorno fa. Aperta
getsentry/toolkit#1595 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di getsentry/toolkit
Issue simili
-
area: image-engine bug priority: low
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
snapotter-hq/SnapOtter#3885 ·
I maintainer di solito rispondono entro 1 giorno
-
Mend: dependency security vulnerability
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 3 giorni
-
pending triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
bug P3 UI/UX
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
openclaw/openclaw#182077 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno