Logger API error handling improvement

Summary: Defer Logger calls to the next tick queue so as to avoid potential Logger errors from falling under the purview of Promise error handling, which would degrade development experience by "swallowing" legitimate runtime errors within rejected promises, to the infuriation of us all :D

Reviewed By: davidaurelio

Differential Revision: D4197869

fbshipit-source-id: 10a44904be1404ad2534d06ddc56048c1c24f32b
This commit is contained in:
Ovidiu Viorel Iepure 2016-11-21 05:57:36 -08:00 committed by Facebook Github Bot
parent 40c3857d23
commit 038cfa8ebe
1 changed files with 6 additions and 2 deletions

View File

@ -475,7 +475,9 @@ class Server {
// This is safe as the asset url contains a hash of the asset. // This is safe as the asset url contains a hash of the asset.
res.setHeader('Cache-Control', 'max-age=31536000'); res.setHeader('Cache-Control', 'max-age=31536000');
res.end(this._rangeRequestMiddleware(req, res, data, assetPath)); res.end(this._rangeRequestMiddleware(req, res, data, assetPath));
process.nextTick(() => {
print(log(createActionEndEntry(processingAssetRequestLogEntry)), ['asset']); print(log(createActionEndEntry(processingAssetRequestLogEntry)), ['asset']);
});
}, },
error => { error => {
console.error(error.stack); console.error(error.stack);
@ -747,7 +749,9 @@ class Server {
}).then( }).then(
stack => { stack => {
res.end(JSON.stringify({stack: stack})); res.end(JSON.stringify({stack: stack}));
process.nextTick(() => {
print(log(createActionEndEntry(symbolicatingLogEntry))); print(log(createActionEndEntry(symbolicatingLogEntry)));
});
}, },
error => { error => {
console.error(error.stack || error); console.error(error.stack || error);