You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fortezhuo opened this issue
Sep 12, 2022
· 3 comments
Labels
bugIssue was opened via the bug report template.UpstreamRelated to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).
I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 21.6.0: Wed Aug 10 14:25:27 PDT 2022; root:xnu-8020.141.5~2/RELEASE_X86_64
Binaries:
Node: 16.15.0
npm: 8.5.5
Yarn: 1.22.18
pnpm: 7.11.0
Relevant packages:
next: 12.3.1-canary.0
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
How are you deploying your application? (if relevant)
Describe the Bug
After upgrade NextJS from 12.2.5 to 12.3.* (include canary) . An error occurs like below statement
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
warn - You have enabled experimental feature (runtime) in next.config.js.
warn - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
warn - You are using the experimental Edge Runtime with `experimental.runtime`.
event - compiled client and server successfully in 1406 ms (232 modules)
wait - compiling / (client and server)...
event - compiled client and server successfully in 860 ms (385 modules)
[Error: A Node.js API is used (setImmediate) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime]
[Error: A Node.js API is used (setImmediate) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime]
wait - compiling /api/trpc/[trpc] (client and server)...
wait - compiling /_error (client and server)...
event - compiled client and server successfully in 318 ms (451 modules)
error - (middleware)/node_modules/.pnpm/@trpc+server@10.0.0-proxy-alpha.74/node_modules/@trpc/server/dist/adapters/next.mjs (11:0) @ getPath
error - Cannot read properties of undefined (reading 'trpc')
null
[TRPCClientError: Unexpected token < in JSON at position 0] {
meta: undefined,
shape: undefined,
data: undefined,
name: 'TRPCClientError'
}
And FYI, I had enabled EdgeRuntime since 12.2.* and run perfectly with TRPC9 and 10
Expected Behavior
setImmediate should not be thrown as error like prev version. And any workaround for this case will be appreciated.
The issue you are seeing appears because tRPC is currently not compatible with the Edge runtime, as the error suggests.
The reason it worked before was caused by a bug that messed up the priorities of API Route runtimes #39462, meaning even if you had a global runtime: "experimental-edge" config, your API route was still using Node.js.
To fix your issue, you can set the following in pages/api/trpc/[trpc].ts:
exportconstconfig={runtime: "nodejs",}
which will ensure to explicitly opt into the Node.js runtime for that API route.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
bugIssue was opened via the bug report template.UpstreamRelated to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).
Verify canary release
Provide environment information
What browser are you using? (if relevant)
How are you deploying your application? (if relevant)
Describe the Bug
After upgrade NextJS from 12.2.5 to 12.3.* (include canary) . An error occurs like below statement
And FYI, I had enabled EdgeRuntime since 12.2.* and run perfectly with TRPC9 and 10
Expected Behavior
setImmediate should not be thrown as error like prev version. And any workaround for this case will be appreciated.
Link to reproduction
https://github.com/trpc/trpc/tree/main/examples/next-minimal-starter
To Reproduce
npx create-next-app --example https://github.com/trpc/trpc --example-path examples/next-minimal-starter trpc-minimal-starter
The text was updated successfully, but these errors were encountered: