mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-22 17:33:23 +01:00
Fix build script errors (#15493)
There is a SES bug that results in errors being printed to the console as `{}`[1]. The known workaround is to print the error stack rather than printing the error directly. This affects our build script when it is run with LavaMoat. We used this workaround in one place in the build script already, but not in the handler for task errors. We now use it in both places. The workaround has been moved to a function that we can use throughout the build script. [1]: https://github.com/endojs/endo/issues/944
This commit is contained in:
parent
42c8703f3e
commit
e3420a4262
@ -63,6 +63,7 @@ const metamaskrc = {
|
||||
const { streamFlatMap } = require('../stream-flat-map');
|
||||
const { BuildType } = require('../lib/build-type');
|
||||
const { BUILD_TARGETS } = require('./constants');
|
||||
const { logError } = require('./utils');
|
||||
|
||||
const {
|
||||
createTask,
|
||||
@ -1053,7 +1054,7 @@ async function createBundle(buildConfiguration, { reloadOnChange }) {
|
||||
if (!reloadOnChange) {
|
||||
bundleStream.on('error', (error) => {
|
||||
console.error('Bundling failed! See details below.');
|
||||
console.error(error.stack || error);
|
||||
logError(error);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ module.exports = {
|
||||
};
|
||||
|
||||
const { setupTaskDisplay } = require('./display');
|
||||
const { logError } = require('./utils');
|
||||
|
||||
async function runTask(taskName, { skipStats } = {}) {
|
||||
if (!(taskName in tasks)) {
|
||||
@ -30,7 +31,7 @@ async function runTask(taskName, { skipStats } = {}) {
|
||||
console.error(
|
||||
`MetaMask build: Encountered an error while running task "${taskName}".`,
|
||||
);
|
||||
console.error(err);
|
||||
logError(err);
|
||||
process.exit(1);
|
||||
}
|
||||
taskEvents.emit('complete');
|
||||
|
@ -51,6 +51,21 @@ function getBrowserVersionMap(platforms, version) {
|
||||
}, {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an error to the console.
|
||||
*
|
||||
* This function includes a workaround for a SES bug that results in errors
|
||||
* being printed to the console as `{}`. The workaround is to print the stack
|
||||
* instead, which does work correctly.
|
||||
*
|
||||
* @see {@link https://github.com/endojs/endo/issues/944}
|
||||
* @param {Error} error - The error to print
|
||||
*/
|
||||
function logError(error) {
|
||||
console.error(error.stack || error);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getBrowserVersionMap,
|
||||
logError,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user