trpc-nuxt icon indicating copy to clipboard operation
trpc-nuxt copied to clipboard

trpc useAsyncQuery/Any query fails with Node.js 18

Open Q16solver opened this issue 2 years ago • 2 comments

Hey! This is a great library that I was trying out with nuxt.js and integrating it, but it was not working for me and after several hours of investigating, it seems like the reason is due to Node.js 18 which brought in the new fetch API, I checked that it's working in Node.js 16, though not sure what the problem is. Hope this can be fixed within this package and that it's not something inherently wrong with nodejs, otherwise please feel free to just close this issue. Here's the stack trace I had from doing client.query

Stack Trace:

TRPCClientError2: fetch failed at Function.from (file:///.../.output/server/chunks/app/server.mjs:5075:14) at file:///.../.output/server/chunks/app/server.mjs:5667:34 { originalError: TypeError: fetch failed at Object.processResponse (node:internal/deps/undici/undici:5555:34) at node:internal/deps/undici/undici:5877:42 at node:internal/process/task_queues:140:7 at AsyncResource.runInAsyncScope (node:async_hooks:203:9) at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8) { cause: InvalidArgumentError: invalid connection header at processHeader (node:internal/deps/undici/undici:2082:15) at new Request (node:internal/deps/undici/undici:1965:13) at [dispatch] (node:internal/deps/undici/undici:2891:25) at Client.dispatch (node:internal/deps/undici/undici:408:33) at [dispatch] (node:internal/deps/undici/undici:627:32) at Pool.dispatch (node:internal/deps/undici/undici:408:33) at [dispatch] (node:internal/deps/undici/undici:4174:27) at Agent.dispatch (node:internal/deps/undici/undici:408:33) at node:internal/deps/undici/undici:6255:83 at new Promise () { code: 'UND_ERR_INVALID_ARG' } }, shape: undefined, data: undefined, isDone: false, [cause]: TypeError: fetch failed at Object.processResponse (node:internal/deps/undici/undici:5555:34) at node:internal/deps/undici/undici:5877:42 at node:internal/process/task_queues:140:7 at AsyncResource.runInAsyncScope (node:async_hooks:203:9) at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8) { cause: InvalidArgumentError: invalid connection header at processHeader (node:internal/deps/undici/undici:2082:15) at new Request (node:internal/deps/undici/undici:1965:13) at [dispatch] (node:internal/deps/undici/undici:2891:25) at Client.dispatch (node:internal/deps/undici/undici:408:33) at [dispatch] (node:internal/deps/undici/undici:627:32) at Pool.dispatch (node:internal/deps/undici/undici:408:33) at [dispatch] (node:internal/deps/undici/undici:4174:27) at Agent.dispatch (node:internal/deps/undici/undici:408:33) at node:internal/deps/undici/undici:6255:83 at new Promise () { code: 'UND_ERR_INVALID_ARG' } } } [Vue warn]: Component <Anonymous> is missing template or render function. [nuxt] [request error] fetch failed at Function.from (./server/chunks/app/server.mjs:5075:14)
at ./server/chunks/app/server.mjs:5667:34

Q16solver avatar Jun 30 '22 14:06 Q16solver

Interesting! Thanks for reporting. Probably related to this https://github.com/trpc/trpc/issues/1895

wobsoriano avatar Jun 30 '22 17:06 wobsoriano

Hi! I am waiting for this PR to get merged for my next update.

wobsoriano avatar Jul 29 '22 18:07 wobsoriano

Fixed https://github.com/wobsoriano/trpc-nuxt/releases/tag/v0.3.0

wobsoriano avatar Sep 24 '22 15:09 wobsoriano