hupe1980 / gatsby-plugin-material-ui

Gatsby plugin for Material-UI with built-in server-side rendering support
MIT License
136 stars 25 forks source link

Build Error #95

Open 14gasher opened 2 years ago

14gasher commented 2 years ago

While building, I get the following error:

failed Building static HTML for pages - 8.205s

 ERROR #95313 

Building static HTML failed

See our docs page for more info on this error: https://gatsby.dev/debug-html

  TypeError: Cannot read properties of null (reading 'split')

  - errors.js:102 createErrorFromString
    [road-rally-frontend]/[gatsby-cli]/lib/reporter/errors.js:102:37

  - build-html.ts:362 doBuildPages
    [road-rally-frontend]/[gatsby]/src/commands/build-html.ts:362:31

  - build-html.ts:450 buildHTMLPagesAndDeleteStaleArtifacts
    [road-rally-frontend]/[gatsby]/src/commands/build-html.ts:450:7

  - build.ts:407 build
    [road-rally-frontend]/[gatsby]/src/commands/build.ts:407:5

This only happens when this plugin is being used. It does not occur if the gatsby emotion is being used.

Dependencies if it helps:

"@emotion/react": "^11.7.1", "@emotion/styled": "^11.6.0", "gatsby": "^4.6.0", "gatsby-plugin-material-ui": "4.1.0", "react": "^17.0.1", "gatsby-source-filesystem": "^4.6.0"

14gasher commented 2 years ago

Found more information:

[Error: undefined (from plugin: gatsby-plugin-material-ui)] {
  type: 'RedirectRequest',
  uri: '/user/login',
  unsafeBuiltinsUsage: [],
  context: { path: '/user/', unsafeBuiltinsUsageByPagePath: {} }
}

This is the error logged from gatsby's renderHTMLQueue.

I'm returning Redirects from unauthorized routes. This might be the issue? Removing the redirects made the build work successfully.

14gasher commented 2 years ago

Replacing all Redirects with navigates wrapped in useEffect makes this work. Would be nice if I could just return a Redirect though haha.