hey-api / openapi-ts

✨ Turn your OpenAPI specification into a beautiful TypeScript client
https://heyapi.vercel.app
Other
967 stars 77 forks source link

Node.js errors seem not caught by the library #794

Closed sneko closed 2 weeks ago

sneko commented 1 month ago

Description

Hi,

I faced an issue where the response content cannot fit into a Node.js string, and this does not throw an error from the client. It just logs:

Error: Cannot create a string longer than 0x1fffffe8 characters
    at TextDecoder.decode (node:internal/encoding:449:16)
    at utf8DecodeBytes (node:internal/deps/undici/undici:2973:34)
    at parseJSONFromBytes (node:internal/deps/undici/undici:4306:25)
    at successSteps (node:internal/deps/undici/undici:4288:27)
    at fullyReadBody (node:internal/deps/undici/undici:2724:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async consumeBody (node:internal/deps/undici/undici:4297:7)
    at getResponseBody (/xxxxxxxx/core/request.ts:217:13)
    at <anonymous> (/xxxxxxxx/core/request.ts:322:26) {
  code: 'ERR_STRING_TOO_LONG'
}

The return parameter is just undefined so I have so use an assertion to throw in case of an error.

I think it should be fixed and at least documented because it break a sensitive logic.

Reproducible example or configuration

No response

OpenAPI specification (optional)

No response

System information (optional)

I'm using the latest version v0.49.0

mrlubos commented 1 month ago

Hey, can you please add a reproducible example?

mrlubos commented 2 weeks ago

@sneko please re-open if you've got a way to reproduce, or I will look if at it if someone else runs into it