Skip to content

[Bug?]: Cannot set headers after they are sent to the client #2025

@harishudewa

Description

@harishudewa

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

I'm trying to use query() with createAsync() in one of my page. Like the following,

// routes/(baseLayout)/index.tsx
import { createAsync, query, redirect, RouteDefinition } from "@solidjs/router";
import { Dialog } from "~/components/Dialog";

const getQuote = query(async () => {
  const quote = await fetch("https://zenquotes.io/api/random");
  throw redirect("/auth/signin");
}, "posts");

function DialogTrigger() {
  return <div>Open dialog</div>;
}

export const route = {
  info: {
    breadcrumbs: {
      label: "Home",
      path: "/",
    },
  },
} satisfies RouteDefinition;

export default function Home() {
  const quote = createAsync(() => getQuote());
  return (
    <div>
      {JSON.stringify(quote())}
      <Dialog trigger={DialogTrigger} />
    </div>
  );
}

But when i go to the page i got the following error:

Image

I tried to refresh the page over and over again, but no hope. Seems like this will occurred when we have fetch() and redirect() altogether. I've tried to change the query() code with just fetch() or redirect() and it's working as expected.

Expected behavior 🤔

No error occurred.

Steps to reproduce 🕹

Steps:

  1. Create query() with fetch() and redirect()
  2. Go to the corresponding page
  3. The error will appeared.

Context 🔦

No response

Your environment 🌎

System:
- OS: macOS Tahoe 26.0
- CPU: Apple M3
Binaries:
- Node: v22.15.0
npmPackages:
- "@solidjs/router": "^0.15.4",
- "@solidjs/start": "^1.2.0",
- "solid-js": "^1.9.10",
- "vinxi": "^0.5.8"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions