fix: preserve error info from streamed_fetch parse failure#1434
Open
OnlookerRs wants to merge 1 commit into
Open
fix: preserve error info from streamed_fetch parse failure#1434OnlookerRs wants to merge 1 commit into
OnlookerRs wants to merge 1 commit into
Conversation
JSON.stringify(error) returns "{}" for Error objects because their
message/name/stack properties are non-enumerable. The previous catch
in fetchNative discarded the real cause:
} catch (e) {
error = JSON.stringify(e) // → always "{}"
}
Downstream callers (custom providers, plugins) then saw `Error: {}`
with no diagnostic value, making bug reports unactionable.
Replace with `e.message || e.name || fallback` to surface the actual
cause (e.g. "Unexpected end of JSON input") in the thrown Error.
cubicj
approved these changes
May 17, 2026
Collaborator
cubicj
left a comment
There was a problem hiding this comment.
Verified the failure path. JSON.stringify(new Error(...)) drops the message to {}, so this preserves useful parse error details without changing the success path or return shape.
Check, tests, and build pass locally.
Approving — thanks for the contribution!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Summary
In
fetchNative()'s Tauri streamed_fetch path (globalApi.svelte.ts), the catch block aroundJSON.parse(res)storesJSON.stringify(e)as the error message. BecauseErrorinstances have non-enumerablemessage/name/stackproperties,JSON.stringify(errorObj)always evaluates to"{}". The downstreamthrow new Error(error)then produces an Error whosemessageis literally the string"{}", and every caller (custom providers, plugins) only seesError: {}with no diagnostic value, making bug reports unactionable.Related Issues
None.
Changes
error = JSON.stringify(e)in the streamed_fetch parse-failure catch withe.message || e.name || 'streamed_fetch parse failed'instanceof Errorguard so non-Error throws still get a sensible string viaString(e)Impact
Unexpected end of JSON input) instead ofError: {}errorremains astring), so the subsequentif (error !== '') throw new Error(error)flow is fully backwards compatibleAdditional Notes
The exact Rust-side condition that produces the malformed/non-JSON response from
invoke('streamed_fetch')is hard to reproduce on demand, but the JS-side bug pattern is trivially verifiable in any runtime:A real user hit this via a custom plugin's error handler — their toast read
캐시 오류 - 요청 취소됨: {}, with the stack pointing at this exact catch viaOB(minifiedfetchNative). With the fix, the same path will now show the underlying cause.Footnotes
Modifies the behavior of prompting, requesting, or handling responses from AI models. ↩
Over 80% of the code is AI generated. ↩