TanStackT
TanStack9mo ago
12 replies
opposite-copper

serverFn signal is always aborted on POST?

I have this server function:
export const getAgents = createServerFn({ method: "GET" }).handler(({ signal }) => {
  console.log("aborted:", signal.aborted)
  return listAgents()
})

which I called with a standard queryFn:
export const agentsQueryOptions = {
  queryKey: ["chat/agents"],
  queryFn: ({ signal }) => {
    return getAgents({ signal } })
  },
}

So far so good. when the query is called it logs aborted: false as expected. However, if I switch method to "POST", something weird happens:

On the first fetch, when called in a loader from the server, aborted is still false. But when I refetch the query from the client, I see aborted: true. Is this a bug?
Was this page helpful?