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

feat(gatsby,gatsby-cli): Slice HTML rendering error handling #36822

Merged
merged 4 commits into from Oct 14, 2022

Conversation

tyhopp
Copy link
Contributor

@tyhopp tyhopp commented Oct 14, 2022

Description

Handle slice HTML rendering errors.

  • Handle generic rendering error with extra context to help with debugging
  • Handle undefined global in SSR error
  • Fix and make generic the undefined global matching logic, add tests

Documentation

N/A

Related Issues

[sc-56605]

@tyhopp tyhopp added the topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) label Oct 14, 2022
@tyhopp tyhopp added this to the Gatsby 5 milestone Oct 14, 2022
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Oct 14, 2022
@tyhopp tyhopp removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Oct 14, 2022
`Slice props: ${JSON.stringify(context?.sliceProps || {}, null, 2)}`,
]
.filter(Boolean)
.join(`\n\n`),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did this instead of stripIndents because stripIndents destroys the format of the stringified JSON

@LekoArts LekoArts merged commit f21b54f into master Oct 14, 2022
@LekoArts LekoArts deleted the feat/slices-html-errors branch October 14, 2022 11:31
`"${context.ref}" is not available during Server-Side Rendering. Enable "DEV_SSR" to debug this during "gatsby develop".`,
`"${context.undefinedGlobal}" is not available during server-side rendering. Enable "DEV_SSR" to debug this during "gatsby develop".`,
Copy link
Contributor

Choose a reason for hiding this comment

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

just heads up on changes like that:

We have error map in gatsby-cli, and gatsby core has that as dependency with ^ selector, which means that older gatsby versions (ones that would create errors with .ref context variable) if they don't have lock file or package manager decide to update gatsby-cli - there might be "incompatibility" between those.

In our case it's not critical because we are in @next / beta phase, so at most previously released alpha/beta versions would be impacted, but change like that is not safe in general.

We should either keep the context variables named as they were (and be annoyed that the name is non-descriptive) or we rename, but the error renderer should be able to fallback to previous name of variable - i.e. "${context.undefinedGlobal ?? context.ref}" ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants