|
16 | 16 | - If the per-code default hint would mislead, supply a hint. If the default suffices, omit the hint. |
17 | 17 | - When you wrap an error, preserve an existing hint and the cause chain. |
18 | 18 | - Every consumer surface must carry at least code, message, and hint. Rehydration helpers copy all fields. |
19 | | -- A failed request inside a request diagnostics scope always flushes diagnostics. A failure before that scope opens may omit `diagnosticId` and `logPath`. Messages must not embed raw stderr dumps or secrets. |
| 19 | +- Thrown request errors attempt one final diagnostics flush. `diagnosticId` requires an active request diagnostics scope, and `logPath` appears only when that flush produces a file. Returned or pre-scope failures may omit both fields. Messages must not embed raw stderr dumps or secrets. |
20 | 20 |
|
21 | 21 | ## Context |
22 | 22 |
|
@@ -78,11 +78,14 @@ Nothing documented the conventions, so each new site decided them again. |
78 | 78 | - Events timeline. |
79 | 79 | Rehydration helpers (`throwDaemonError`, `toDaemonHttpRpcError`) copy all fields. |
80 | 80 | `NormalizedError` hoists the typed signals, so `--json` consumers see them. |
81 | | -6. **Observability.** A failed request inside a request diagnostics scope always flushes diagnostics. |
82 | | - Inside that scope on the local machine, the error carries a `diagnosticId` and an ndjson `logPath`. |
83 | | - The router opens the scope at `handleRequestOnLedger` (`packages/daemon/src/server/request-router.ts`). |
84 | | - A failure before it opens, such as malformed RPC method params rejected in |
85 | | - `packages/daemon/src/server/http/http-rpc-methods.ts`, returns an envelope that omits both fields. |
| 81 | +6. **Observability.** Thrown request errors reach `finalizeThrownRequestError` |
| 82 | + (`packages/daemon/src/server/request-router.ts`), which emits a `request_failed` diagnostic and attempts one forced |
| 83 | + flush. It attaches a `diagnosticId` only when a request diagnostics scope is active, and an ndjson |
| 84 | + `logPath` only when that flush produces a file; the flush returns no record for zero events or a write failure. |
| 85 | + `withDiagnosticsScope` itself runs no finalizer. |
| 86 | + A returned (not thrown) failure, such as the token refusal in `runRequestWithinScope`, and a pre-scope |
| 87 | + failure, such as malformed RPC method params rejected in |
| 88 | + `packages/daemon/src/server/http/http-rpc-methods.ts`, omit both fields. |
86 | 89 | On a remote path, the client keeps only a `logPath` it can open. |
87 | 90 | When it cannot produce one, `logPathUnavailable` replaces `logPath` and names the reason (#1801). |
88 | 91 | Daemon-side diagnostics are under the session state dir. |
|
0 commit comments