Skip to content

Commit 89ee441

Browse files
committed
update
1 parent 4633f0a commit 89ee441

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/routes/solid-start/building-your-application/data-fetching.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ In this example, the `getCurrentUserQuery` retrieves the session data, and if an
4242
Otherwise, it redirects the user to the login page.
4343
All of these operations are performed completely on the server regardless of how the query is called.
4444

45-
:::caution[Redirects and streaming don't mix]
46-
HTTP redirects work by setting a `3xx` status code on the response.
47-
Once a response has started streaming, its headers (including the status code) are already sent to the client and cannot be changed, even if the stream hasn't finished yet.
45+
:::caution[Modifying headers after streaming]
46+
Once a response starts streaming, its headers (including the status code and cookies) are immediately sent to the client and **cannot be modified**.
4847

49-
If a server function attempts to redirect after streaming has begun, you'll encounter the common error:
48+
Any server-side operation that changes headers, such as performing a redirect (`3xx` status) or using APIs like `useSession` that modify cookies, must happen **before** streaming begins.
49+
Otherwise, you'll encounter errors like:
5050

5151
**"Cannot set headers after they are sent to the client."**
5252

53-
To avoid this, disable streaming for queries that may perform a redirect by enabling the [`deferStream`](/solid-router/reference/data-apis/create-async#deferstream) option.
53+
To avoid this, disable streaming for queries that may modify headers by enabling the [`deferStream`](/solid-router/reference/data-apis/create-async#deferstream) option.
5454

5555
```tsx
5656
const user = createAsync(() => getCurrentUserQuery(), { deferStream: true });

0 commit comments

Comments
 (0)