Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log uncaught source-mapped errors to the console #446

Merged
merged 1 commit into from
Nov 30, 2022

Conversation

mrbbot
Copy link
Contributor

@mrbbot mrbbot commented Nov 23, 2022

Previously, errors thrown using the MF-Experimental-Error-Stack header were only shown in a pretty-error page. This PR logs those errors with source-maps applied to the console too, using the source-map-support package. This simplifies our code, and also means we don't need to touch internal Youch methods, as the errors we pass to Youch are already source-mapped.

@mrbbot mrbbot added the tre Relating to Miniflare 3 label Nov 23, 2022
@mrbbot mrbbot added this to the 3.0.0 milestone Nov 23, 2022
@changeset-bot
Copy link

changeset-bot bot commented Nov 23, 2022

⚠️ No Changeset found

Latest commit: 2341ed8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

packages/tre/src/plugins/core/errors/callsite.ts Outdated Show resolved Hide resolved
packages/tre/src/plugins/core/errors/index.ts Show resolved Hide resolved
const sourceFile = maybeGetFile(workerSrcOpts, file);
if (sourceFile?.path === undefined) return null;

// Find the last source mapping URL if any
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the last?

Copy link
Contributor Author

@mrbbot mrbbot Nov 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sourceMappingURL may appear in earlier comments/string-literals and we want to ignore those. This is what source-map-support and get-source (dependency of stacktracey) do.

packages/tre/src/plugins/core/errors/index.ts Outdated Show resolved Hide resolved
packages/tre/src/plugins/core/errors/index.ts Show resolved Hide resolved
packages/tre/src/plugins/core/errors/index.ts Show resolved Hide resolved
packages/tre/src/plugins/core/errors/sourcemap.ts Outdated Show resolved Hide resolved
Previously, errors _thrown_ using the `MF-Experimental-Error-Stack`
header were only shown in a pretty-error page. This PR logs those
errors with source-maps applied to the console too, using the
`source-map-support` package. This simplifies our code, and also
means we don't need to touch internal Youch methods, as the errors
we pass to Youch are already source-mapped.
@mrbbot mrbbot force-pushed the tre-log-source-mapped-errors branch from 53f8850 to 2341ed8 Compare November 24, 2022 17:25
@mrbbot mrbbot requested a review from penalosa November 24, 2022 17:26
@mrbbot mrbbot merged commit a7d0f63 into tre Nov 30, 2022
@mrbbot mrbbot deleted the tre-log-source-mapped-errors branch November 30, 2022 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tre Relating to Miniflare 3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants