Skip to content

Commit

Permalink
Bump stack trace limit when TS is used
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten committed Jul 30, 2024
1 parent 7bcdac9 commit 08da4ed
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/cli-utils/src/ts/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ export interface ProgramFactory {
build(): ProgramContainer;
}

/** Bumps the Error stack traces to a length of 100 for better debugging. */
const bumpStackTraceLimit = () => {
if ('stackTraceLimit' in Error && Error.stackTraceLimit < 25) {
Error.stackTraceLimit = 25;
}
};

export const programFactory = (params: ProgramFactoryParams): ProgramFactory => {
const vfsMap = new Map<string, string>();
const virtualMap: VirtualMap = new Map();
Expand Down Expand Up @@ -154,6 +161,8 @@ export const programFactory = (params: ProgramFactoryParams): ProgramFactory =>
},

build() {
bumpStackTraceLimit();

// NOTE: This is necessary for `@0no-co/graphqlsp/api` to use the right instance
// of the typescript library
init({ typescript: ts });
Expand Down

0 comments on commit 08da4ed

Please sign in to comment.