Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function frameToString(frame)
{
const wrappedFrame = wrapCallSite(frame)
var sourceFile = wrappedFrame.getFileName()
var functionName = wrappedFrame.getFunctionName()
var typeName = wrappedFrame.getTypeName()
// Ignore some cryptic function names which typically are just function calls
if (FUNCTION_NAME_CLEARANCE.some((regexp) => regexp.test(functionName))) {
functionName = ""
}
// Filter out configured type names
if (TYPE_NAME_CLEARANCE.some((regexp) => regexp.test(typeName))) {
typeName = ""
}
// Strip out generated filename part from source field
export function frameToString(frame)
{
const wrappedFrame = wrapCallSite(frame)
var sourceFile = wrappedFrame.getFileName()
var functionName = wrappedFrame.getFunctionName()
var typeName = wrappedFrame.getTypeName()
// Ignore some cryptic function names which typically are just function calls
if (FUNCTION_NAME_CLEARANCE.some((regexp) => regexp.test(functionName))) {
functionName = ""
}
// Filter out configured type names
if (TYPE_NAME_CLEARANCE.some((regexp) => regexp.test(typeName))) {
typeName = ""
}
// Strip out generated filename part from source field
export function isRelevantFrame(frame) {
const wrappedFrame = wrapCallSite(frame);
const generatedFile = frame.getFileName();
const sourceFile = wrappedFrame.getFileName();
const functionName = wrappedFrame.getFunctionName();
// Filter out all raw files which do not have any source mapping
// This typically removes most of the build related infrastructure
// which is neither application or framework code.
const isCompiled = sourceFile !== generatedFile;
if (!isCompiled) {
return false;
}
// Filter out specific functions e.g. webpack require wrappers
if (FUNCTION_NAME_FILTERS.some(regexp => regexp.test(functionName))) {
return false;
export function isRelevantFrame(frame)
{
const wrappedFrame = wrapCallSite(frame)
const generatedFile = frame.getFileName()
var sourceFile = wrappedFrame.getFileName()
var functionName = wrappedFrame.getFunctionName()
// Filter out all raw files which do not have any source mapping
// This typically removes most of the build related infrastructure
// which is neither application or framework code.
const isCompiled = sourceFile !== generatedFile
if (!isCompiled) {
return false
}
// Filter out specific functions e.g. webpack require wrappers
if (FUNCTION_NAME_FILTERS.some((regexp) => regexp.test(functionName))) {
return false
function processFrameFn (frame: Object): Object {
// fixes a weird bug with `wrapCallSite`
frame.isNative = () => false
let file = frame.getFileName()
frame = wrapCallSite(frame)
if (file.includes('fakeit')) {
file = file.replace('dist', 'src')
.replace(/jsx$/, 'js')
frame.getFileName = () => file
frame.getScriptNameOrSourceURL = () => file
}
return frame
}
export function prepareStackTrace(nativeError, structuredStackTrace) {
const frames = getRelevantFrames(structuredStackTrace);
const firstFrame = frames[0];
// Need the first frame for highlighting affected source code, sometimes that's not available.
if (firstFrame != null) {
const wrappedFirstFrame = wrapCallSite(firstFrame);
const sourceFile = cleanSourceFileName(wrappedFirstFrame.getFileName());
let sourceText = '';
try {
sourceText = readFileSync(sourceFile, 'utf-8');
} catch (error) {
// Ignore errors
}
// Generate highlighted code frame and attach it to the native error object (for later usage)
if (sourceText) {
const result = codeFrame(
sourceText,
wrappedFirstFrame.getLineNumber(),
wrappedFirstFrame.getColumnNumber(),
CODE_FRAME_OPTIONS,
function frameToString(frame)
{
const wrappedFrame = wrapCallSite(frame)
const name = wrappedFrame.getFunctionName() || `${wrappedFrame.getTypeName()}.`
const sourceFilePointer = wrappedFrame.getFileName()
const generatedFile = frame.getFileName()
const lineNumber = wrappedFrame.getLineNumber()
const columnNumber = wrappedFrame.getColumnNumber()
const isCompiled = sourceFilePointer !== generatedFile
let sourceFile = generatedFile
if (isCompiled)
sourceFile = `.${sourceFilePointer.split(":")[1]}`
else if (!SHOW_EXTENDED_STACKTRACE)
return null
const toParsed = () => ({
name,
return error + stack.map(function(frame) {
return '\n at ' + sourceMapSupport.wrapCallSite(frame);
}).join('');
}