Commit 798f26f
authored
fix(test): handle NDJSON chunking in log_stream tests (#4358)
The log endpoint streams NDJSON (newline-delimited JSON) generated by
`tracing-subscriber`. However, the log stream tests assume each HTTP
body chunk contains a complete JSON object, which isn't necessarily the
case.
HTTP streaming doesn't guarantee chunk boundaries align with JSON
boundaries because TCP can split data anywhere. This causes occasional
test failures when chunks split mid-JSON-object in my local machine.
Fix by buffering incoming chunks and extracting complete lines (by
newline delimiter) before parsing as JSON.
We could arguably set the content type header for this endpoint to
`application/x-ndjson` to be fully compliant with the NDJSON specs, but
that that may be risking a breaking change for little value.
Signed-off-by: Alejandro Martinez Ruiz <amr@buoyant.io>1 parent 730c626 commit 798f26f
1 file changed
Lines changed: 28 additions & 3 deletions
Lines changed: 28 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| 216 | + | |
216 | 217 | | |
217 | 218 | | |
218 | 219 | | |
| |||
227 | 228 | | |
228 | 229 | | |
229 | 230 | | |
230 | | - | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
231 | 256 | | |
232 | 257 | | |
233 | 258 | | |
234 | 259 | | |
235 | | - | |
236 | | - | |
| 260 | + | |
| 261 | + | |
237 | 262 | | |
238 | 263 | | |
239 | 264 | | |
| |||
0 commit comments