Skip to content

Commit 718d693

Browse files
gatsbybotLekoArts
andauthoredAug 2, 2022
fix(gatsby): Add DEV_SSR note to 95312 error (#36295) (#36300)
Co-authored-by: Lennart <lekoarts@gmail.com>

File tree

7 files changed

+25
-8
lines changed

7 files changed

+25
-8
lines changed
 

‎docs/docs/debugging-html-builds.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Errors while building static HTML files (the build-time React SSR process) or wh
3535

3636
5. Some other reason :-) #1 is the most common reason building static files
3737
fail. If it's another reason, you have to be a bit more creative in figuring
38-
out the problem.
38+
out the problem. The [`DEV_SSR` feature](#ssr-during-gatsby-develop) can help you with this.
3939

4040
## How to check if `window` is defined
4141

@@ -106,3 +106,20 @@ exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
106106
```
107107
108108
Another solution is to use a package like [loadable-components](https://github.com/gregberge/loadable-components). The module that tries to use `window` will be dynamically loaded only on the client side (and not during SSR).
109+
110+
## SSR during `gatsby develop`
111+
112+
Server-Side render (SSR) pages on full reloads during `gatsby develop`. This helps you detect SSR bugs and fix them without needing to do full builds with `gatsby build`. Once enabled, go to your desired page and do a full reload (e.g. Ctrl + R or F5).
113+
114+
Add the `DEV_SSR` flag to your `gatsby-config.js`:
115+
116+
```js:title=gatsby-config.js
117+
module.exports = {
118+
flags: {
119+
DEV_SSR: true
120+
},
121+
plugins: [...]
122+
}
123+
```
124+
125+
Please give feedback in the [DEV_SSR umbrella discussion](https://github.com/gatsbyjs/gatsby/discussions/28138).

‎docs/docs/glossary/server-side-rendering.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Server Side Rendering
2+
title: Server-Side Rendering
33
disableTableOfContents: true
44
---
55

‎docs/docs/how-to/local-development/troubleshooting-common-errors.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ The following errors are related to styles in your site, using CSS, preprocessor
9191
9292
### Inconsistent CSS styles between develop and build using styled-components or emotion
9393
94-
_NOTE: We're in process of adding SSR support to the develop server. To use it now, enable the `DEV_SSR` flag in your gatsby-config.js — https://github.com/gatsbyjs/gatsby/discussions/28138_
95-
9694
A common problem that trips up users that install and begin to use styled-components or emotion is not including the related plugin in the config. Because `gatsby develop` doesn't run server-side rendering, the build may look different if the plugin is not included to tell Gatsby to server-side render the styles for the CSS-in-JS solution being used.
9795
9896
Adding `gatsby-plugin-styled-components` (in the case of styled-components) or `gatsby-plugin-emotion` (in the case of emotion) to `gatsby-config.js` will inform Gatsby to process the styles server-side so they display correctly in the final build.
9997
98+
You can use the [`DEV_SSR` feature flag](/docs/debugging-html-builds#ssr-during-gatsby-develop) inside your `gatsby-config` to enable SSR support during `gatsby develop` which can help you debug such issues.
99+
100100
## Errors with GraphQL
101101
102102
Gatsby's GraphQL data layer provides access to build time data, there are sometimes errors you may encounter while implementing plugins that are sourcing data or adding nodes to the schema yourself.

‎integration-tests/gatsby-cli/__tests__/build-ssr-errors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe(`gatsby build (SSR errors)`, () => {
1616
logs.should.contain(`failed Building static HTML for pages`)
1717
logs.should.contain(`ERROR #95312`)
1818
logs.should.contain(
19-
`"window" is not available during server side rendering.`
19+
`"window" is not available during Server-Side Rendering.`
2020
)
2121
logs.should.contain(
2222
`See our docs page for more info on this error: https://gatsby.dev/debug-html`

‎packages/gatsby-cli/src/reporter/__tests__/__snapshots__/index.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Object {
130130
"docsUrl": "https://gatsby.dev/debug-html",
131131
"level": "ERROR",
132132
"stack": Array [],
133-
"text": "\\"navigator\\" is not available during server side rendering.",
133+
"text": "\\"navigator\\" is not available during Server-Side Rendering. Enable \\"DEV_SSR\\" to debug this during \\"gatsby develop\\".",
134134
}
135135
`;
136136

‎packages/gatsby-cli/src/structured-errors/error-map.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const errors = {
3434
},
3535
"95312": {
3636
text: (context): string =>
37-
`"${context.ref}" is not available during server side rendering.`,
37+
`"${context.ref}" is not available during Server-Side Rendering. Enable "DEV_SSR" to debug this during "gatsby develop".`,
3838
level: Level.ERROR,
3939
docsUrl: `https://gatsby.dev/debug-html`,
4040
category: ErrorCategory.USER,

‎packages/gatsby/src/utils/flags.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const activeFlags: Array<IFlag> = [
9797
command: `develop`,
9898
telemetryId: `DevSsr`,
9999
experimental: false,
100-
description: `Server Side Render (SSR) pages on full reloads during develop. Helps you detect SSR bugs and fix them without needing to do full builds. See umbrella issue for how to update custom webpack config.`,
100+
description: `Server Side Render (SSR) pages on full reloads during develop. Helps you detect SSR bugs and fix them without needing to do full builds.`,
101101
umbrellaIssue: `https://gatsby.dev/dev-ssr-feedback`,
102102
testFitness: (): fitnessEnum => true,
103103
},

0 commit comments

Comments
 (0)
Please sign in to comment.