发布

  • Add pretty-error page infrastructure (#436)

    frostbyte_neo 发布于 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 have stacks. 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/catchs too.

    下载附件