Skip to content

Commit bb34bce

Browse files
author
Andy
authored
Set a high stack trace limit in command-line and server scenarios (#17464)
1 parent c969807 commit bb34bce

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/compiler/sys.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ declare function setTimeout(handler: (...args: any[]) => void, timeout: number):
44
declare function clearTimeout(handle: any): void;
55

66
namespace ts {
7+
/**
8+
* Set a high stack trace limit to provide more information in case of an error.
9+
* Called for command-line and server use cases.
10+
* Not called if TypeScript is used as a library.
11+
*/
12+
/* @internal */
13+
export function setStackTraceLimit() {
14+
if ((Error as any).stackTraceLimit < 100) { // Also tests that we won't set the property if it doesn't exist.
15+
(Error as any).stackTraceLimit = 100;
16+
}
17+
}
18+
719
export enum FileWatcherEventKind {
820
Created,
921
Changed,

src/compiler/tsc.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,8 @@ namespace ts {
665665
}
666666
}
667667

668+
ts.setStackTraceLimit();
669+
668670
if (ts.Debug.isDebugging) {
669671
ts.Debug.enableDebugInfo();
670672
}

src/server/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,8 @@ namespace ts.server {
757757
validateLocaleAndSetLanguage(localeStr, sys);
758758
}
759759

760+
setStackTraceLimit();
761+
760762
const typingSafeListLocation = findArgument(Arguments.TypingSafeListLocation);
761763
const npmLocation = findArgument(Arguments.NpmLocation);
762764

0 commit comments

Comments
 (0)