Fix: default to status 200 for non-empty DatastarResponse (Litestar)#39
Open
tompassarelli wants to merge 1 commit intostarfederation:developfrom
Open
Conversation
Litestar's Stream base class defaults to status 201 when no status_code
is provided. Datastar's client-side fetch action (RC8) only processes
SSE responses with status 200 — non-200 responses are silently discarded:
// fetch.ts line 561
if (status !== 200) { dispose(); resolve(); return; }
The empty-content case already defaults to 204. This adds the same
pattern for the non-empty case: default to 200 when the caller doesn't
specify a status code.
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.
Problem
Litestar's
Streambase class defaults to status201when nostatus_codeis provided. Datastar's client-side fetch action (v1.0.0-RC.8) only processes SSE responses with status200:This means every
DatastarResponsewith content silently fails — the browser receives the SSE stream, but Datastar discards it without processing anypatch-elementsorpatch-signalsevents.Fix
One line: default to
200when content is present and no explicit status code is given. Same pattern already used for the empty-content204case.Impact
Without this fix, every Litestar app using
DatastarResponsemust either:status_code=200on every callDatastarResponseto override the defaultBoth are non-obvious workarounds for what should be a sensible default.