Skip to content

Conversation

@amirhhashemi
Copy link
Collaborator

This is complementary to #1385.

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@netlify
Copy link

netlify bot commented Dec 24, 2025

Deploy Preview for solid-docs ready!

Name Link
🔨 Latest commit 5dcda3c
🔍 Latest deploy log https://app.netlify.com/projects/solid-docs/deploys/6950d6b6fe3ec100086d6c07
😎 Deploy Preview https://deploy-preview-1386--solid-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment on lines 46 to 49
Once a response starts streaming, its headers (including the status code and cookies) are immediately sent to the client and **cannot be modified**.

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.
Otherwise, you'll encounter errors like:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Once a response starts streaming, its headers (including the status code and cookies) are immediately sent to the client and **cannot be modified**.
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.
Otherwise, you'll encounter errors like:
Once streaming begins, response headers (including status and cookies) are sent and cannot be changed.
Any header-modifying logic, such as redirects or APIs that set cookies, must run before streaming starts, or an error will occur.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated it with two changes:

  1. I kept useSession as an example. It's a very common source of the error.
  2. I mentioned that this only happens when the logic is executed on the server.

Comment on lines +50 to +58

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

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

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**"Cannot set headers after they are sent to the client."**
To avoid this, disable streaming for queries that may modify headers by enabling the [`deferStream`](/solid-router/reference/data-apis/create-async#deferstream) option.
```tsx
const user = createAsync(() => getCurrentUserQuery(), { deferStream: true });
```
To avoid this, disable streaming for queries that may modify headers by enabling the [`deferStream`](/solid-router/reference/data-apis/create-async#deferstream):
```tsx
const user = createAsync(() => getCurrentUserQuery(), { deferStream: true });

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep the error message. It's a common and vague message, and people might try to search it in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants