Skip to content

Commit 453a60d

Browse files
committed
fix: enhance stack logging in middleware to support different stack modes
1 parent 6ce9221 commit 453a60d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

packages/vite/src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,12 @@ function attachMiddleware(server: any, options: ResolvedOptions) {
223223
if (options.fileLog.enabled) {
224224
const time = new Date().toISOString();
225225
const toFile = [`[${time}] ${line}`];
226-
if (entry.stack && options.stackMode !== 'none') toFile.push(indent(entry.stack, ' '));
226+
if (entry.stack && options.stackMode !== 'none') {
227+
const stackLines = options.stackMode === 'full'
228+
? indent(entry.stack, ' ')
229+
: ` ${(String(entry.stack).split(/\r?\n/g).find((l) => l.trim().length > 0) || '').trim()}`;
230+
toFile.push(stackLines);
231+
}
227232
try { appendFileSync(logFilePath, toFile.join('\n') + '\n'); } catch {}
228233
}
229234
}

0 commit comments

Comments
 (0)