mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Get rid of res.clone() (#1567)
Usually res.clone() should work. But it's not working with the laster Safari (10.1) We need to use a method we do not clone
This commit is contained in:
parent
66ab661d4c
commit
d32e69eeb9
|
@ -288,7 +288,14 @@ export default class Router {
|
||||||
}
|
}
|
||||||
|
|
||||||
const jsonPageRes = await this.fetchRoute(route)
|
const jsonPageRes = await this.fetchRoute(route)
|
||||||
const jsonData = await jsonPageRes.json()
|
let jsonData
|
||||||
|
// We can call .json() only once for a response.
|
||||||
|
// That's why we need to keep a copy of data if we already parsed it.
|
||||||
|
if (jsonPageRes.data) {
|
||||||
|
jsonData = jsonPageRes.data
|
||||||
|
} else {
|
||||||
|
jsonData = jsonPageRes.data = await jsonPageRes.json()
|
||||||
|
}
|
||||||
|
|
||||||
if (jsonData.buildIdMismatch) {
|
if (jsonData.buildIdMismatch) {
|
||||||
_notifyBuildIdMismatch(as)
|
_notifyBuildIdMismatch(as)
|
||||||
|
@ -336,16 +343,13 @@ export default class Router {
|
||||||
return props
|
return props
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchRoute (route) {
|
fetchRoute (route) {
|
||||||
let promise = this.fetchingRoutes[route]
|
let promise = this.fetchingRoutes[route]
|
||||||
if (!promise) {
|
if (!promise) {
|
||||||
promise = this.fetchingRoutes[route] = this.doFetchRoute(route)
|
promise = this.fetchingRoutes[route] = this.doFetchRoute(route)
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await promise
|
return promise
|
||||||
// We need to clone this to prevent reading the body twice
|
|
||||||
// Because it's possible only once to read res.json() or a similar method.
|
|
||||||
return res.clone()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
doFetchRoute (route) {
|
doFetchRoute (route) {
|
||||||
|
|
Loading…
Reference in a new issue