Commit 2b52ffd
committed
fix: decode only the viewed bytes of Uint8Array log data
When execution-id logging is enabled, stdout/stderr writes are
intercepted and re-decoded to attach execution context. The Uint8Array
branch decoded `data.buffer`, which is the entire backing ArrayBuffer
and ignores the view's `byteOffset`/`byteLength`.
Node.js allocates most Buffers from a shared internal pool, so a Buffer
written to stdout is frequently a view with a non-zero byteOffset into a
much larger ArrayBuffer. Decoding `data.buffer` therefore captured
unrelated pool bytes surrounding the real message, producing corrupted
log output (e.g. logging the whole 8 KiB pool instead of "hello world").
Decode `Buffer.from(data.buffer, data.byteOffset, data.byteLength)` so
only the bytes the view spans are read. Added a regression test that
logs through a pooled, non-zero-offset view.1 parent 7d08f3b commit 2b52ffd
2 files changed
Lines changed: 21 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
167 | 175 | | |
168 | 176 | | |
169 | 177 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
150 | 162 | | |
151 | 163 | | |
152 | 164 | | |
| |||
0 commit comments