Skip to content

Commit

Permalink
Fail on Invalid Prerender Manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Feb 10, 2020
1 parent a33e365 commit f25da29
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions packages/next/next-server/server/spr-cache.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import fs from 'fs'
import path from 'path'
import LRUCache from 'lru-cache'
import mkdirpOrig from 'mkdirp'
import path from 'path'
import { promisify } from 'util'
import { PrerenderManifest } from '../../build'
import { PRERENDER_MANIFEST } from '../lib/constants'
import { normalizePagePath } from './normalize-page-path'
import mkdirpOrig from 'mkdirp'

const mkdirp = promisify(mkdirpOrig)
const readFile = promisify(fs.readFile)
Expand Down Expand Up @@ -72,14 +72,12 @@ export function initializeSprCache({
!dev && (typeof flushToDisk !== 'undefined' ? flushToDisk : true),
}

try {
prerenderManifest = dev
? { routes: {}, dynamicRoutes: [] }
: JSON.parse(
fs.readFileSync(path.join(distDir, PRERENDER_MANIFEST), 'utf8')
)
} catch (_) {
prerenderManifest = { version: 1, routes: {}, dynamicRoutes: {} }
if (dev) {
prerenderManifest = { version: -1, routes: {}, dynamicRoutes: {} }
} else {
prerenderManifest = JSON.parse(
fs.readFileSync(path.join(distDir, PRERENDER_MANIFEST), 'utf8')
)
}

cache = new LRUCache({
Expand Down

0 comments on commit f25da29

Please sign in to comment.