MCPcopy
hub / github.com/vitejs/vite / ssrFixStacktrace

Function ssrFixStacktrace

packages/vite/src/node/ssr/ssrStacktrace.ts:94–113  ·  view source on GitHub ↗
(
  e: Error,
  moduleGraph: EnvironmentModuleGraph,
)

Source from the content-addressed store, hash-verified

92const rewroteStacktraces = new WeakSet()
93
94export function ssrFixStacktrace(
95 e: Error,
96 moduleGraph: EnvironmentModuleGraph,
97): void {
98 if (!e.stack) return
99 // stacktrace shouldn't be rewritten more than once
100 if (rewroteStacktraces.has(e)) return
101
102 const { result: stacktrace, alreadyRewritten } = ssrRewriteStacktrace(
103 e.stack,
104 moduleGraph,
105 )
106 rebindErrorStacktrace(e, stacktrace)
107 if (alreadyRewritten) {
108 e.message +=
109 ' (The stacktrace appears to be already rewritten by something else, but was passed to vite.ssrFixStacktrace. This may cause incorrect stacktraces.)'
110 }
111
112 rewroteStacktraces.add(e)
113}

Callers 2

instantiateModuleFunction · 0.90
ssrFixStacktraceFunction · 0.90

Calls 4

rebindErrorStacktraceFunction · 0.85
hasMethod · 0.80
addMethod · 0.80
ssrRewriteStacktraceFunction · 0.70

Tested by

no test coverage detected