Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch(cli-utils): Bump stack trace limit when TypeScript is used #355

Merged
merged 3 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ten-owls-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@gql.tada/cli-utils": patch
---

Bump stack trace limit to 25 when TypeScript is used, which requires a larger stack depths to debug properly.
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. */
kitten marked this conversation as resolved.
Show resolved Hide resolved
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
Loading