Skip to content
Source
Sign inSign up
TanStack/query

Does not work with edge runtime #5575

Send to my agent
Closedrawsh(GitHub profile, opens in a new tab) opened this issue 1 comment

Describe the bug

Setting a page to use edge-runtime does not work. This is a big blocker for deploying to cloudflare pages.

Failed to compile.

./node_modules/.pnpm/@tanstack+react-query@4.29.12_react-dom@18.2.0_react@18.2.0/node_modules/@tanstack/react-query/build/lib/reactBatchedUpdates.mjs
Attempted import error: 'unstable_batchedUpdates' is not exported from 'react-dom' (imported as 'ReactDOM').

Import trace for requested module:
./node_modules/.pnpm/@tanstack+react-query@4.29.12_react-dom@18.2.0_react@18.2.0/node_modules/@tanstack/react-query/build/lib/reactBatchedUpdates.mjs
./node_modules/.pnpm/@tanstack+react-query@4.29.12_react-dom@18.2.0_react@18.2.0/node_modules/@tanstack/react-query/build/lib/setBatchUpdatesFn.mjs
./node_modules/.pnpm/@tanstack+react-query@4.29.12_react-dom@18.2.0_react@18.2.0/node_modules/@tanstack/react-query/build/lib/index.mjs
./src/@trpc/next-layout/client/createHydrateClient.tsx
./src/@trpc/next-layout/client/index.ts
./src/lib/api/client.ts
./src/app/(dank)/layout.tsx

Your minimal, reproducible example

Github

Steps to reproduce

Clone a nextjs repo using tanstack query https://github.com/ploskovytskyy/next-app-router-trpc-drizzle-planetscale-edge

Add export const runtime = "edge"; to any page.tsx file that imports api

Expected behavior

Should work on edge runtime

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

V8 engine

Tanstack Query adapter

None

TanStack Query version

4.29.12

TypeScript version

No response

Additional context

No response

  1. how is this a bug in react-query? According to an issue we had too long ago:

    Edge runtime causes this problem as apparently it creates its own dom where unstable_batchedUpdates is not exported

    Anyways, unstable_batchedUpdates is removed in v5.

  2. TkDodo closed this

  3. TkDodo added labelsv5

Sign in to join this conversation.