Commit 919aecc
committed
fix data-channel-write error wrap to preserve context cancellation identity
pkg/handlers/default.go:139 wrapped the CancellableWrite failure with %v,
which dropped context.DeadlineExceeded / context.Canceled from the
errors.Is chain on the returned ErrProcessingFatal. The downstream
measureLatencyAndHandleErrors classifier uses
errors.Is(err, context.DeadlineExceeded) to increment the timeout metric
and apply the "error processing chunk" framing; with %v that branch was
unreachable for this failure path, causing the timeout metric to
under-count and the chunk-processing framing to be missing.
Switching to %w preserves both the outer ErrProcessingFatal wrap (so
isFatal still classifies correctly) and the inner ctx.Err() identity
(so the timeout classifier fires). Multiple %w verbs in a single
fmt.Errorf are supported on Go 1.20+; this repo is on Go 1.24.
Same shape as #4929's fix at line 137 but feeds a different
classifier (metric correctness rather than control flow).
Adds a regression test that constructs a dead context, drives a
chunk-error through handleNonArchiveContent against an unbuffered
output channel to force CancellableWrite to fail, and asserts both
the outer ErrProcessingFatal wrap and the inner ctx.Err() identity
are preserved for both DeadlineExceeded and Canceled.1 parent cf31c26 commit 919aecc
2 files changed
Lines changed: 66 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
| |||
117 | 119 | | |
118 | 120 | | |
119 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
0 commit comments