mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
cc9d87c365
Occasionally our builds have been failing with the error "Unexpected end of JSON input", with a stack pointing at `lavamoat-core`. The file in question was reading the policy, reading overrides, merging them, then writing the policy back to disk. The intermittent errors can be explained if the policy file was read in one process while it was being written in another. The extension build script builds bundles in multiple processes in parallel, so it does follow that this would happen some of the time. This could result in a partial policy file being read by the build script, resulting in a JSON parsing error. This has been fixed by removing the policy write step using a patch. We don't need this step. We update the policy using a different function altogether, and we have a CI job to ensure we never forget to update it.
19 lines
956 B
Diff
19 lines
956 B
Diff
diff --git a/src/loadPolicy.js b/src/loadPolicy.js
|
|
index ef71923f9282d6a5e9f74e6ec6fa0516f28f508b..0118fda7e1b0fa461ec01ceff8d7112d072f3dfb 100644
|
|
--- a/src/loadPolicy.js
|
|
+++ b/src/loadPolicy.js
|
|
@@ -33,10 +33,9 @@ async function loadPolicyAndApplyOverrides({ debugMode, policyPath, policyOverri
|
|
}
|
|
const policyOverride = await readPolicyFile({ debugMode, policyPath: policyOverridePath })
|
|
lavamoatPolicy = mergePolicy(policy, policyOverride)
|
|
- // TODO: Only write if merge results in changes.
|
|
- // Would have to make a deep equal check on whole policy, which is a waste of time.
|
|
- // mergePolicy() should be able to do it in one pass.
|
|
- fs.writeFileSync(policyPath, jsonStringify(lavamoatPolicy, { space: 2 }))
|
|
+ // Skip policy write step to prevent intermittent build failures
|
|
+ // The extension validates the policy in a separate step, we don't need it
|
|
+ // to be written to disk here.
|
|
}
|
|
return lavamoatPolicy
|
|
}
|