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

Prisma.JsonValue occurs Maximum call stack size exceeded #346

Closed
dohyuu opened this issue May 16, 2023 · 9 comments
Closed

Prisma.JsonValue occurs Maximum call stack size exceeded #346

dohyuu opened this issue May 16, 2023 · 9 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers

Comments

@dohyuu
Copy link
Contributor

dohyuu commented May 16, 2023

Bug Report

Summary

When there is a Prisma.JsonValue type in the User model of Prisma, an error occurs.

Actual behavior: error occurred

Maximum call stack size exceeded - src/app.controller.ts.8:49.
// schema.prisma

model User {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?

  // here
  content Json?
  posts Post[]
}

model Post {
  id        Int     @id @default(autoincrement())
  title     String
  content   String?
  published Boolean @default(false)
  author    User    @relation(fields: [authorId], references: [id])
  authorId  Int
}
// app.contoller.ts

@Controller('/')
export class AppController {
  /**
   * Maximum call stack size exceeded
   */
  @TypedRoute.Get()
  callStackExceeded(): User[] {
    return [];
  }

  /**
   * Ok
   */
  @TypedRoute.Get()
  noProblem(): Post[] {
    return [];
  }
}

If I comment out callStackExceeded, no error occurs.

Code occuring the bug

repo: https://github.com/dohyuu/nestia-reproduce

git clone https://github.com/dohyuu/nestia-reproduce
cd ./nestia-reproduce
npm i
npm run db:gen
npm run start:dev
@dohyuu dohyuu changed the title Prisma.JsonValue occurs Maximum call stack size exceeded Prisma.JsonValue occurs Maximum call stack size exceeded May 16, 2023
@dohyuu
Copy link
Contributor Author

dohyuu commented May 16, 2023

  export type JsonObject = {[Key in string]?: JsonValue}

  /**
   * From https://github.com/sindresorhus/type-fest/
   * Matches a JSON array.
   */
  export interface JsonArray extends Array<JsonValue> {}

  /**
   * From https://github.com/sindresorhus/type-fest/
   * Matches any valid JSON value.
   */
  export type JsonValue = string | number | boolean | JsonObject | JsonArray | null

Here is the Prisma.JsonValue type.

@DavidVaness
Copy link
Contributor

Just ran into this today

@samchon
Copy link
Owner

samchon commented May 25, 2023

@dohyuu Due to type JsonValue = ... | JsonValue[] declaration, analyzing is not possible.

What about just using any type in that case?

@samchon
Copy link
Owner

samchon commented May 25, 2023

@DavidVaness This issue needs entire refactoring in typia. I'll do this. Thanks

@samchon samchon self-assigned this May 25, 2023
@samchon samchon added bug Something isn't working enhancement New feature or request good first issue Good for newcomers labels May 25, 2023
@dohyuu
Copy link
Contributor Author

dohyuu commented May 25, 2023

@samchon I solved the problem with a prisma interface generator that was customized for me. (Prisma.JsonValue is also replaced with any.)

Thank you for your answer.

@samchon
Copy link
Owner

samchon commented Jun 3, 2023

@dohyuu @DavidVaness

Building and publishing next version of nestia.

After a day, upgrade to @nestia/core@1.3.0 and @nestia/sdk@1.3.0, then everything would be fine.

@DavidVaness
Copy link
Contributor

Thank you @samchon
Will report back on Monday

samchon added a commit that referenced this issue Jun 3, 2023
To support #346 issue, `typia` has been entirely reconstructed, and break changes on API being occured.

Therefore, upgraded minor version of `nestia`, and configured `peerDependencies` to have minimum `typia@4.0.0` version
@DavidVaness
Copy link
Contributor

DavidVaness commented Jun 20, 2023

@samchon I have updated to the latest typia + nestia and the issue persists. Only way is to remap the Prisma.JsonValue to any or some other type.

Seems like its not fixed

samchon added a commit to samchon/nestia-issue-346 that referenced this issue Jun 20, 2023
samchon added a commit to samchon/nestia-issue-346 that referenced this issue Jun 20, 2023
@samchon
Copy link
Owner

samchon commented Jun 20, 2023

@DavidVaness Tested your code, but there's not any problem.

Which version are you using?

If same error being repeated, can you provide me a reproducable repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants