TypeError: Cannot read properties of null (reading '_def')
As the title says, I get the following:
TypeError: Cannot read properties of null (reading '_def')
at isRouter (/app/node_modules/@trpc/server/dist/config-3ab6b85e.js:52:42)
at recursiveGetPaths (/app/node_modules/@trpc/server/dist/config-3ab6b85e.js:84:21)
at createRouterInner (/app/node_modules/@trpc/server/dist/config-3ab6b85e.js:94:9)
at appRouter (/app/dist/routers/_app.js:19:49)
at startServer (/app/dist/server.js:56:20)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
I might have some sort of malconfigured something, but I have no idea where to start looking. Can anyone point me in the right direction?
5 Replies
Are your trpc versions all the same?
yeah they are 🤔
i can say it's started happening since we updated from 10.18 -> 10.41
@Nick Lucas sorry for the ping.
Basically in 10.18, we had a router definition like
fooRouter = __DEV__ ? someRouter() : (null)
This actually worked back then and is now breaking.Interesting, I don’t think it’s a usage pattern we really were aware of. What happens if instead of null you pass an empty router?
Empty router works fine, admittedly
null
was not a good original choice (my fault).That seems the sanest solution then 🙂