This repository was archived by the owner on Mar 13, 2025. It is now read-only.
Commit f42ea31
authored
Add pretty-error page infrastructure (#436)
This adds Miniflare 2's pretty-error page powered by
[Youch](https://github.com/poppinss/youch) to Miniflare 3.
Unfortunately, due to a bug in `workerd`, errors thrown
asynchronously by native APIs don't have `stack`s. This means we
can't extract the `stack` trace from dispatching to the user worker
by `try`/`catch`.
As a stop-gap solution, if the `MF-Experimental-Error-Stack` header
exists and is truthy on the response from the user worker, the body
will be interpreted as a JSON-error of the form
`{ message?: string, name?: string, stack?: string }`. `stack` will
be source-mapped if possible.
Another issue is that `workerd` gives all service-worker scripts the
name "worker.js", so if multiple service-workers are defined, we
can't identify which one threw. In this case, we don't display
sources in the pretty-error page.
Hopefully, we can fix both of these issues in `workerd`. We should be
able to reuse most of this infrastructure with `try`/`catch`s too.1 parent 7a78784 commit f42ea31
File tree
7 files changed
+547
-22
lines changed- packages/tre
- src
- plugins/core
7 files changed
+547
-22
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
226 | 231 | | |
227 | 232 | | |
228 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| 43 | + | |
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
31 | 36 | | |
32 | 37 | | |
33 | 38 | | |
| |||
345 | 350 | | |
346 | 351 | | |
347 | 352 | | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
348 | 358 | | |
349 | 359 | | |
350 | 360 | | |
| |||
0 commit comments