T
tRPC

@trpc/server in a non-server environment Error in Azure CI

@trpc/server in a non-server environment Error in Azure CI

MMugetsu2/8/2023
Im trying to add vitest unit tests for my trpc procedures. I followed some examples and on the local evn all works. Tests pass but in the Azure CI I get this error.
Error: You're trying to use @trpc/server in a non-server environment. This is not supported by default.
#19 7.732 ❯ initTRPCInner node_modules/.pnpm/@trpc+server@10.8.1/node_modules/@trpc/server/dist/inde***.mjs:808:23
#19 7.732 ❯ TRPCBuilder.create node_modules/.pnpm/@trpc+server@10.8.1/node_modules/@trpc/server/dist/inde***.mjs:782:33
#19 7.732 ❯ src/server/api/trpc.ts:32:56
#19 7.734 30| import { createTRPCConte***t } from './conte***t'
#19 7.734 31|
#19 7.734 32| const t = initTRPC.conte***t<typeof createTRPCConte***t>().create({
#19 7.734 | ^
#19 7.734 33| transformer: superjson,
#19 7.734 34| errorFormatter({ shape, ct*** }) {
Error: You're trying to use @trpc/server in a non-server environment. This is not supported by default.
#19 7.732 ❯ initTRPCInner node_modules/.pnpm/@trpc+server@10.8.1/node_modules/@trpc/server/dist/inde***.mjs:808:23
#19 7.732 ❯ TRPCBuilder.create node_modules/.pnpm/@trpc+server@10.8.1/node_modules/@trpc/server/dist/inde***.mjs:782:33
#19 7.732 ❯ src/server/api/trpc.ts:32:56
#19 7.734 30| import { createTRPCConte***t } from './conte***t'
#19 7.734 31|
#19 7.734 32| const t = initTRPC.conte***t<typeof createTRPCConte***t>().create({
#19 7.734 | ^
#19 7.734 33| transformer: superjson,
#19 7.734 34| errorFormatter({ shape, ct*** }) {
Nnlucas2/8/2023
You've probably imported your Backend into the Frontend Make sure where you're importing the AppRouter you're doing import type { AppRouter } from 'backend' Or you just need to set up your tests project to include the Node environment, it may be browser by default
MMugetsu2/8/2023
mmm this might be it but why it works locally then
Nnlucas2/8/2023
Sometimes the mode of tools changes when CI=1 is set in the environment. This would be a weird case of that though
MMugetsu2/8/2023
@Nick Lucas Thanks for the tip! You were right. I've changed default setting for vitest from environment: 'jsdom', to per file via comment and it worked ❤️

Looking for more? Join the community!

T
tRPC

@trpc/server in a non-server environment Error in Azure CI

Join Server
Recommended Posts
How are people handling authorization?I noticed that with V10, any mentions of `trpc-shield` are gone from the documentation. Also, it onlVitest context router callerHi, Im trying to setup vitest to test trpc. I would like to have a trpc approuter caller to be accesCannot read properties of undefined (reading 'data') of res.error.data, when trpc errors outHello everyone, I am using `@trpc/react-query` alongside `trpc` for express, and I am experiencing aExtending middlewareshttps://trpc.io/docs/middlewares#extending-middlewares Is this available?Calling a trpc endpoint inside of a trpc endpointHey all. I'm wondering how I am able to call these endpoints from within themselves? For example,Frozen input paramIs it possible to define a parameter on input schema (zod) that will have a hardcoded/frozen value wtype mismatch between tRPC return (in sveltekit) and defined typei've got this piece of code: ```ts read: async () => { const res = await trpc($page).getCards.querpre fetch serveral prodecures dynamicallyHello!. I'm developing a React Native app which needs an offline mode for some assets that the user procedure input contextIs it possible to accesss context in trpc procedure input validation? I have an aray of values in tIs it normal to separate resolvers from routers?Wondering if it's common and/or whether it's a good idea to attempt to separate procedures from the i have an infinite loop within my hook but apps works as expected.when i console log inside this hook, it repeats non-stop every few seconds, but my app is working astrpc query running twiceHey guys. I have a trpc endpoint which makes a request to the discord api to fetch a list of the usetRPC Call To ServerOn the mobile version of my app, in NextJS, the build has to be static so I have to use my hosted weGet count of stages assigned to user with stage name?Need help in writing prisma query to get stages assigned to user with stage name? this is the scheme