From d32e69eeb91edfa79eded2f4f8f8d178a0803e30 Mon Sep 17 00:00:00 2001 From: Arunoda Susiripala Date: Thu, 30 Mar 2017 19:39:31 +0530 Subject: [PATCH] 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 --- lib/router/router.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/router/router.js b/lib/router/router.js index aaba0862f6..b54f741387 100644 --- a/lib/router/router.js +++ b/lib/router/router.js @@ -288,7 +288,14 @@ export default class Router { } 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) { _notifyBuildIdMismatch(as) @@ -336,16 +343,13 @@ export default class Router { return props } - async fetchRoute (route) { + fetchRoute (route) { let promise = this.fetchingRoutes[route] if (!promise) { promise = this.fetchingRoutes[route] = this.doFetchRoute(route) } - const res = await 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() + return promise } doFetchRoute (route) { -- GitLab