#3483·ava

(高严重级未捕获的 TypeError): 在匿名或 Eval 堆栈帧中在 `serializeError` 中发生了未处理的异常

作者: codeCraft-Ritik创建于 2026年9月15日更新于 2026年9月15日
标签needs triage

In lib/serialize-error.js lines 15–38:

javascript
function normalizeFile(file, ...base) {
  return file.startsWith('file://') ? file : pathToFileURL(path.resolve(...base, file)).toString();
}

const stackUtils = new StackUtils();
function extractSource(stack, testFile) {
  if (!stack || !testFile) {
    return null;
  }

  testFile = normalizeFile(testFile);

  for (const line of stack.split('\n')) {
-	const callSite = stackUtils.parseLine(line);
+	if (callSite && normalizeFile(callSite.file) === testFile) {
	    return {
	      isDependency: false,
	      isWithinProject: true,
	      file: testFile,
	      line: callSite.line,
	    };
	  }
  }

  return null;
}

If any line in stack is: at <anonymous> stackUtils.parseLine produces: { line: undefined, column: undefined, file: undefined, function: '<anonymous>' }. callSite is truthy, but callSite.file is undefined. normalizeFile(undefined) executes undefined.startsWith(...), crashing with an unhandled TypeError.

Proposed Fix