mirror of https://github.com/status-im/metro.git
[JSAppServer] Don't keep track of not found packages
This commit is contained in:
parent
f47a29f922
commit
06f508a55a
|
@ -372,12 +372,36 @@ Server.prototype.processRequest = function(req, res, next) {
|
|||
Activity.endEvent(startReqEventId);
|
||||
}
|
||||
},
|
||||
function(error) {
|
||||
handleError(res, error);
|
||||
}
|
||||
this._handleError.bind(this, res, optionsJson)
|
||||
).done();
|
||||
};
|
||||
|
||||
Server.prototype._handleError = function(res, packageID, error) {
|
||||
res.writeHead(error.status || 500, {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
});
|
||||
|
||||
if (error.type === 'TransformError' || error.type === 'NotFoundError') {
|
||||
error.errors = [{
|
||||
description: error.description,
|
||||
filename: error.filename,
|
||||
lineNumber: error.lineNumber,
|
||||
}];
|
||||
res.end(JSON.stringify(error));
|
||||
|
||||
if (error.type === 'NotFoundError') {
|
||||
delete this._packages[packageID];
|
||||
}
|
||||
} else {
|
||||
console.error(error.stack || error);
|
||||
res.end(JSON.stringify({
|
||||
type: 'InternalError',
|
||||
message: 'react-packager has encountered an internal error, ' +
|
||||
'please check your terminal error output for more details',
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
function getOptionsFromUrl(reqUrl) {
|
||||
// `true` to parse the query param as an object.
|
||||
var urlObj = url.parse(reqUrl, true);
|
||||
|
@ -417,26 +441,3 @@ function getBoolOptionFromQuery(query, opt, defaultVal) {
|
|||
|
||||
return query[opt] === 'true' || query[opt] === '1';
|
||||
}
|
||||
|
||||
function handleError(res, error) {
|
||||
res.writeHead(error.status || 500, {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
});
|
||||
|
||||
if (error.type === 'TransformError' || error.type === 'NotFoundError') {
|
||||
error.errors = [{
|
||||
description: error.description,
|
||||
filename: error.filename,
|
||||
lineNumber: error.lineNumber,
|
||||
}];
|
||||
console.error(error);
|
||||
res.end(JSON.stringify(error));
|
||||
} else {
|
||||
console.error(error.stack || error);
|
||||
res.end(JSON.stringify({
|
||||
type: 'InternalError',
|
||||
message: 'react-packager has encountered an internal error, ' +
|
||||
'please check your terminal error output for more details',
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue