Commit bb6eb87
committed
[miniflare] Improve error diagnostics in the Browser Run binding worker
When the local Browser Run binding failed to reach an upstream — for
example when Chrome failed to launch and miniflare's loopback
`/browser/launch` endpoint returned a 500 with a stack-trace text
body — the binding worker would call `response.json()` on the non-JSON
body and throw an opaque `SyntaxError: Unexpected token X, "..." is not
valid JSON`. The actual upstream error message (e.g. `Chrome readiness
probe at ... timed out after 5000ms`) was discarded.
Add a `parseJsonResponse` helper to the binding worker that reads the
body as text first, surfaces the HTTP status and (truncated) body
content in the thrown error, and chains the original `SyntaxError` via
`cause` when the body was a 2xx response that didn't parse as JSON.
Wire it into the three loopback JSON-parsing sites in the binding
worker (`/browser/launch`, `/browser/sessionIds`, and per-DO
session-info reads).
This makes both local-dev failures and CI test flakes self-diagnosing
without requiring a debugger.1 parent 304d498 commit bb6eb87
2 files changed
Lines changed: 67 additions & 9 deletions
File tree
- .changeset
- packages/miniflare/src/workers/browser-rendering
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
Lines changed: 58 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 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 | + | |
73 | 113 | | |
74 | 114 | | |
75 | 115 | | |
| |||
445 | 485 | | |
446 | 486 | | |
447 | 487 | | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
453 | 495 | | |
454 | 496 | | |
455 | 497 | | |
| |||
458 | 500 | | |
459 | 501 | | |
460 | 502 | | |
461 | | - | |
462 | | - | |
463 | | - | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
464 | 510 | | |
465 | 511 | | |
466 | 512 | | |
467 | 513 | | |
468 | 514 | | |
469 | 515 | | |
470 | 516 | | |
471 | | - | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
472 | 521 | | |
473 | 522 | | |
474 | 523 | | |
| |||
0 commit comments