From c0721c0174220cba80d227d70b659d46da77656b Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 1 Dec 2018 14:11:10 +0330 Subject: [PATCH] fix(vue-renderer): parse JSON values before passing to bundle-renderer prevent error that occuers in rare cases: TypeError: Cannot read property 'sections' of undefined Related to #4439 --- packages/vue-renderer/src/renderer.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/vue-renderer/src/renderer.js b/packages/vue-renderer/src/renderer.js index 57a4743204..e21e2e37a5 100644 --- a/packages/vue-renderer/src/renderer.js +++ b/packages/vue-renderer/src/renderer.js @@ -389,19 +389,23 @@ export default class VueRenderer { transform: (src, { readResource, oldValue = { files: {}, maps: {} } }) => { const serverManifest = JSON.parse(src) - const resolveAssets = (obj, oldObj, encoding) => { + const resolveAssets = (obj, oldObj, isJSON) => { Object.keys(obj).forEach((name) => { - obj[name] = readResource(obj[name], encoding) + obj[name] = readResource(obj[name]) // Try to reuse deleted MFS files if no new version exists if (!obj[name]) { obj[name] = oldObj[name] } + // Parse JSON + if (isJSON) { + obj[name] = JSON.parse(obj[name]) + } }) return obj } const files = resolveAssets(serverManifest.files, oldValue.files) - const maps = resolveAssets(serverManifest.maps, oldValue.maps, 'utf-8') + const maps = resolveAssets(serverManifest.maps, oldValue.maps, true) return { ...serverManifest,