Skip to content

Commit

Permalink
fix(gatsby): fix codepaths that result in js errors (#21829)
Browse files Browse the repository at this point in the history
  • Loading branch information
wardpeet authored Mar 2, 2020
1 parent dc484eb commit a87f1bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/gatsby/cache-dir/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,9 @@ const createComponentUrls = componentChunkName =>
export class ProdLoader extends BaseLoader {
constructor(asyncRequires, matchPaths) {
const loadComponent = chunkName =>
asyncRequires.components[chunkName]().then(preferDefault)
asyncRequires.components[chunkName]
? asyncRequires.components[chunkName]().then(preferDefault)
: Promise.resolve()

super(loadComponent, matchPaths)
}
Expand Down
3 changes: 3 additions & 0 deletions packages/gatsby/cache-dir/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ const navigate = (to, options = {}) => {
if (!pageResources || pageResources.status === `error`) {
window.history.replaceState({}, ``, location.href)
window.location = pathname
clearTimeout(timeoutId)
return
}

// If the loaded page has a different compilation hash to the
// window, then a rebuild has occurred on the server. Reload.
if (process.env.NODE_ENV === `production` && pageResources) {
Expand Down

0 comments on commit a87f1bd

Please sign in to comment.