| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
When API responses return empty or malformed JSON, the SDK now provides actionable error messages including HTTP status and URL instead of cryptic 'Unexpected end of JSON input' errors. Changes: - Wrap response.json() in try-catch for both v1 and v2 clients - Include response status and URL in error message - Preserve original error as cause for debugging - Route errors through interceptors for custom handling
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Sorry, something went wrong.
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
Sorry, something went wrong.
|
You can't just manually edit auto generated code, this will be deleted next time stuff is regenerated |
Sorry, something went wrong.
|
Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
When API responses return empty or malformed JSON (e.g., network interruption, API timeout, truncated response), the SDK now provides actionable error messages instead of cryptic SyntaxError: Unexpected end of JSON input.
Problem
The current implementation calls response.json() directly without error handling:
When the API returns an incomplete response, users see:
SyntaxError: Unexpected end of JSON input at json (unknown) at <anonymous> (../sdk/js/src/v2/gen/client/client.gen.ts:167:33)This provides no context about what went wrong or how to debug it.
Solution
Wrap response.json() in try-catch and provide enhanced error messages:
After this fix:
Changes
Note
These files are auto-generated by @hey-api/openapi-ts. This is a temporary fix until upstream handles JSON parsing errors gracefully. The fix will need to be reapplied after regeneration, or ideally contributed upstream to @hey-api/client-fetch.