Commit 6b7f7bc
feat: route unhandled rejections through sendTelemetryError for richer error data
Production cluster `unhandlederror` with `Channel closed` (~45 unique
machines on 0.61.x, mostly Win32) was opaque even after the
`error.name`/`error.message`/`error.code` visibility fix in #1928 — that
fix only applies to events emitted via our `sendTelemetryError` helper.
Uncaught promise rejections fire VS Code's built-in `unhandlederror`
event from `@vscode/extension-telemetry`'s
`baseTelemetrySender.sendErrorData`, which only forwards `name` /
`message` / `stack` and **drops `error.code`**. That's the field that
distinguishes IPC failure modes (`ERR_IPC_CHANNEL_CLOSED`, `EPIPE`,
`EBADF`, `ECONNRESET`, ...) — without it, every `Channel closed` event
looks identical in App Insights regardless of root cause.
Add a `process.on('unhandledRejection')` listener in
`DBTPowerUserExtension.activate(context)` that routes the rejection
reason through `this.telemetry.sendTelemetryError("unhandledRejection",
reason)`. The helper already handles `error_name` / `error_message` /
`error_code` extraction (`telemetry/index.ts:128-133`) plus the standard
`dbtIntegrationMode` / `instanceName` / `localMode` envelope. The new
event has a distinct name (`unhandledRejection`, camelCase) from VS
Code's upstream `unhandlederror` (lowercase) so the two streams stay
queryable separately in App Insights — both will fire for each uncaught
rejection going forward, but the new one is enriched.
Listener is registered as a `context.subscriptions` disposable so it
unhooks on extension deactivation, preventing handler accumulation
across reload cycles. Telemetry failures inside the listener are
swallowed (try/catch) so a broken telemetry pipeline can't recursively
re-enter the rejection path.
Adds `src/test/suite/unhandledRejectionRouting.test.ts` with four cases
covering (1) the routing happy path, (2) `error.code` propagation,
(3) dispose unhooks the listener, and (4) a throwing telemetry stub
doesn't re-enter the rejection path. Tests drive `process.emit` directly
because Jest registers its own `unhandledRejection` listener for failure
reporting, which interferes with letting a real `Promise.reject` bubble
naturally.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 68ef665 commit 6b7f7bc
2 files changed
Lines changed: 149 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
96 | 121 | | |
97 | 122 | | |
98 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
0 commit comments