collectInfoFromStacktrace() — astro Function Reference
Architecture documentation for the collectInfoFromStacktrace() function in utils.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD e8f7378a_0237_7b9f_5d0b_f10ec6dbb971["collectInfoFromStacktrace()"] 6382d0b9_8ae6_1f6a_25b6_41a3e8e6de51["utils.ts"] e8f7378a_0237_7b9f_5d0b_f10ec6dbb971 -->|defined in| 6382d0b9_8ae6_1f6a_25b6_41a3e8e6de51 8d0d4acd_8384_a2c6_5b17_55868e5cf72d["collectErrorMetadata()"] 8d0d4acd_8384_a2c6_5b17_55868e5cf72d -->|calls| e8f7378a_0237_7b9f_5d0b_f10ec6dbb971 0edfb3ef_2f1d_89c9_d757_12a3bf25180c["cleanErrorStack()"] e8f7378a_0237_7b9f_5d0b_f10ec6dbb971 -->|calls| 0edfb3ef_2f1d_89c9_d757_12a3bf25180c style e8f7378a_0237_7b9f_5d0b_f10ec6dbb971 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/core/errors/dev/utils.ts lines 163–219
function collectInfoFromStacktrace(error: SSRError & { stack: string }): StackInfo {
let stackInfo: StackInfo = {
stack: error.stack,
plugin: error.plugin,
pluginCode: error.pluginCode,
loc: error.loc,
};
// normalize error stack line-endings to \n
stackInfo.stack = normalizeLF(error.stack);
const stackText = stripVTControlCharacters(error.stack);
// Try to find possible location from stack if we don't have one
if (!stackInfo.loc || (!stackInfo.loc.column && !stackInfo.loc.line)) {
const possibleFilePath =
error.loc?.file ||
error.pluginCode ||
error.id ||
// TODO: this could be better, `src` might be something else
stackText
.split('\n')
.find((ln) => ln.includes('src') || ln.includes('node_modules'));
// Disable eslint as we're not sure how to improve this regex yet
// eslint-disable-next-line regexp/no-super-linear-backtracking
const source = possibleFilePath?.replace?.(/^[^(]+\(([^)]+).*$/, '$1').replace(/^\s+at\s+/, '');
let file = source?.replace(/:\d+/g, '');
const location = /:(\d+):(\d+)/.exec(source!) ?? [];
const line = location[1];
const column = location[2];
if (file && line && column) {
try {
file = fileURLToPath(file);
} catch {}
stackInfo.loc = {
file,
line: Number.parseInt(line),
column: Number.parseInt(column),
};
}
}
// Derive plugin from stack (if possible)
if (!stackInfo.plugin) {
stackInfo.plugin =
/withastro\/astro\/packages\/integrations\/([\w-]+)/i.exec(stackText)?.at(1) ||
/(@astrojs\/[\w-]+)\/(server|client|index)/i.exec(stackText)?.at(1) ||
undefined;
}
// Normalize stack (remove `/@fs/` urls, etc)
stackInfo.stack = cleanErrorStack(error.stack);
return stackInfo;
}
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does collectInfoFromStacktrace() do?
collectInfoFromStacktrace() is a function in the astro codebase, defined in packages/astro/src/core/errors/dev/utils.ts.
Where is collectInfoFromStacktrace() defined?
collectInfoFromStacktrace() is defined in packages/astro/src/core/errors/dev/utils.ts at line 163.
What does collectInfoFromStacktrace() call?
collectInfoFromStacktrace() calls 1 function(s): cleanErrorStack.
What calls collectInfoFromStacktrace()?
collectInfoFromStacktrace() is called by 1 function(s): collectErrorMetadata.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free