mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
ea817fd7f5
Summary: Metro symbolication can be expensive in large apps. However, there is no need to symbolicate _runtime stacks from compile errors_. Those are pretty much useless anyway. This will reduce the workload on Metro workers, and the delays when iterating with Fast Refresh, as the server will be busy much less often. So I'm special-casing them and not sending the symbolication request anymore. Reviewed By: rickhanlonii Differential Revision: D16030087 fbshipit-source-id: 41f83ac01780c0a60cca777014e4ed95c0f3d14b
39 lines
845 B
JavaScript
39 lines
845 B
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
* @flow
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
import type {StackFrame} from '../NativeExceptionsManager';
|
|
|
|
export type ExtendedError = Error & {
|
|
framesToPop?: number,
|
|
jsEngine?: string,
|
|
preventSymbolication?: boolean,
|
|
};
|
|
|
|
function parseErrorStack(e: ExtendedError): Array<StackFrame> {
|
|
if (!e || !e.stack) {
|
|
return [];
|
|
}
|
|
|
|
const stacktraceParser = require('stacktrace-parser');
|
|
const stack = Array.isArray(e.stack)
|
|
? e.stack
|
|
: stacktraceParser.parse(e.stack);
|
|
|
|
let framesToPop = typeof e.framesToPop === 'number' ? e.framesToPop : 0;
|
|
while (framesToPop--) {
|
|
stack.shift();
|
|
}
|
|
return stack;
|
|
}
|
|
|
|
module.exports = parseErrorStack;
|