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

fix: avoid suppressing errors when loading pages for ssr fails #8813

Merged
merged 6 commits into from
Feb 1, 2023

Conversation

gtm-nayan
Copy link
Contributor

closes #8799

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

@changeset-bot
Copy link

changeset-bot bot commented Jan 31, 2023

🦋 Changeset detected

Latest commit: 4889c81

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

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

Copy link
Member

@benmccann benmccann left a comment

Choose a reason for hiding this comment

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

thank you!! fyi, it looks like this needs a rebase

/** @param {string} id */
async function resolve(id) {
const url = id.startsWith('..') ? `/@fs${path.posix.resolve(id)}` : `/${id}`;

const module = await vite.ssrLoadModule(url);
let module = await vite.ssrLoadModule(url).catch((error) => {
Copy link
Member

Choose a reason for hiding this comment

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

wow, this is fantastic! I didn't know about buildErrorMessage

I see another half dozen places where ssrLoadModule is called. Maybe we also need this same code in those places? We could make a utility function that calls ssrLoadModule

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pulling that rebase commit back to my local took me way longer than it should have, hah.

I'll look at the other locations tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added it to the other 2 places where we're loading user modules,
for the ones generated by Kit, there's already a generic error page with the stack trace that's rendered, probably don't need it there.

@Rich-Harris Rich-Harris merged commit 33a8fad into master Feb 1, 2023
@Rich-Harris Rich-Harris deleted the regurgitate-errors branch February 1, 2023 17:10
@Rich-Harris
Copy link
Member

huge improvement!

@github-actions github-actions bot mentioned this pull request Feb 1, 2023
@@ -50,11 +50,25 @@ export async function dev(vite, vite_config, svelte_config) {
/** @type {Error | null} */
let manifest_error = null;

/** @param {string} url */
async function loud_ssr_load_module(url) {
Copy link
Member

Choose a reason for hiding this comment

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

Loud. Lol

Copy link
Member

Choose a reason for hiding this comment

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

Oh I thought it was a typo for load, but then I just noticed load is in the name later on, so maybe it's not a typo 🤣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SvelteKit swallows parse errors
3 participants