PinkiePie
PinkiePie
Explore posts from servers
TtRPC
Created by PinkiePie on 12/27/2024 in #❓-help
trpc doesn't work after migrating to next 15
thank you! ❤️
15 replies
TtRPC
Created by PinkiePie on 12/27/2024 in #❓-help
trpc doesn't work after migrating to next 15
https://github.com/trpc/trpc/issues/6341 - however it's mostly just a copy-paste of the discussion above, i don't have an isolated project where issue can be reproduced 😦
15 replies
TtRPC
Created by PinkiePie on 12/27/2024 in #❓-help
trpc doesn't work after migrating to next 15
@Alex / KATT 🐱 it seems like i narrowed down the issue to the exact file and commit 🙂 The change was introduced in this commit/line: https://github.com/trpc/trpc/commit/87fde62978441b1cedd1d5cf7290f6ade9a92607#diff-981f2f06bfbbee188e14a4f7991f370e9042eb5c21995e24e183ab76acc5ce01R136 and then here https://github.com/trpc/trpc/commit/3df8b21beb4925cf73194fc776d1a88603a3c420#diff-981f2f06bfbbee188e14a4f7991f370e9042eb5c21995e24e183ab76acc5ce01L136 req.socket exists locally with node, but it seems like it doesn't exist in lambdas environment (next adapter with netlify backed by aws). so, it fails on this line. In this env, request object is an instance of ComputeJsIncomingMessage class - I don't really know if it comes from next itself, or from lambdas, it's what i've seen when i put console.log in trpc code using yarn patch. It looks like this issue has nothing to do with nextjs upgrade, but with the fact i didn't pin exact trpc version but used "@trpc/server": "next", and it was unintentionally upgraded together with nextjs. As a temporary workaround i reverted it back to a version before this change was introduced (11.0.0-rc.608), and now everything works fine
15 replies
TtRPC
Created by PinkiePie on 12/27/2024 in #❓-help
trpc doesn't work after migrating to next 15
btw it's trpc 11.0.0-rc.666 and next 15.1.2 if it's anyhow could help
15 replies
TtRPC
Created by PinkiePie on 12/27/2024 in #❓-help
trpc doesn't work after migrating to next 15
@Alex / KATT 🐱
import { createNextApiHandler } from '@trpc/server/adapters/next';
import { createContext } from '../../../../lambdas/src/trpc/context';
import { appRouter } from '../../../../lambdas/src/trpc/router/_app';

// export API handler
export default createNextApiHandler({
router: appRouter,
createContext,
onError:
process.env.NODE_ENV === 'development'
? ({ path, error }) => {
console.error(`❌ tRPC failed on ${path}: ${error}`);
}
: undefined,
});

export const config = {
api: {
bodyParser: false,
responseLimit: '20mb',
},
};
import { createNextApiHandler } from '@trpc/server/adapters/next';
import { createContext } from '../../../../lambdas/src/trpc/context';
import { appRouter } from '../../../../lambdas/src/trpc/router/_app';

// export API handler
export default createNextApiHandler({
router: appRouter,
createContext,
onError:
process.env.NODE_ENV === 'development'
? ({ path, error }) => {
console.error(`❌ tRPC failed on ${path}: ${error}`);
}
: undefined,
});

export const config = {
api: {
bodyParser: false,
responseLimit: '20mb',
},
};
it works locally both with dev/prod build (both yarn next dev and yarn next build && yarn next start) , the issue happens only when i deploy to netlify
15 replies
TtRPC
Created by PinkiePie on 12/27/2024 in #❓-help
trpc doesn't work after migrating to next 15
btw, the issue is only with [trpc].ts routes; the ones that uses SSR with getServerSideProps works fine. and it also works fine locally, it fails only in prod (aws lambdas backed by netlify)
15 replies
TtRPC
Created by thomasplayschess on 9/13/2023 in #❓-help
Wrapping useQuery into a custom hook
does anybody know how to solve it with up-to-date trpc?
74 replies
PPrisma
Created by PinkiePie on 5/19/2024 in #help-and-questions
how to return an empty array instead of null
@Nurul (Prisma) yep, i use composite types, so I had to do the thing you proposed for every model which uses my type. it works, and it achieved the desired outcome, but it feels like a dirty workaround anyway. prisma doesn't have optional lists. Why then it returns me a null instead of an empty array? That's a misleading DX. Prisma should either allow optional lists in the schema, so m Int[]? will produce number[] | null type, and force me to check the array before accessing it, or it should return an empty array by default instead of null. Currently, the field m can be nullable on the database level (for example if I pass it undefined during create operation, but the generated TS type shows like it can be never optional. So, I will have to add the check if the field m everywhere, but the devs after me would try to remove it as "unnecessary" check (type in TS and schema clearly shows that it's a mandatory field). So, your solution works as a temporary fix, but for sure it's something wrong on Prisma's side. Either return [] by default instead of null, or allow us to mark lists as optional in schema, so we will generate correct TS types
5 replies