-
Add pretty-error page infrastructure (#436)
发布于
2023-11-01 14:27:07 +00:00 This adds Miniflare 2's pretty-error page powered by
Youch to Miniflare 3.Unfortunately, due to a bug in
workerd, errors thrown
asynchronously by native APIs don't havestacks. This means we
can't extract thestacktrace from dispatching to the user worker
bytry/catch.As a stop-gap solution, if the
MF-Experimental-Error-Stackheader
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 }.stackwill
be source-mapped if possible.Another issue is that
workerdgives 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 withtry/catchs too.下载附件