-
-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use Server Actions + Monorepo setup - TypeError: Cannot read properties of undefined (reading 'getRequestConfig') #1229
Comments
TLDR: Importing and using |
Why do you intend to wrap/re-export Can you provide some background? |
I am doing it like that because I have multiple packages that need to use the I believe that this error is sometimes occuring because getRequestConfig is not able to be found. The strange thing is that this behavior is quite inconsistent and sometimes does work.... |
Thanks for providing details! Where do you draw the line here? I mean, you also wouldn't map libraries like React, Next.js or lodash if they are used in multiple packages, right? I'd really suggest to import functionality from Regarding React Native, you can absolutely import from As for the issue you've reported, I unfortunately don't know where this originates from—sorry! As it only occurs in production and apparently only sometimes, this might sound rather hairy to debug. |
@amannn , thanks for the detailed response. About drawing the line for exports from a separate package, I guess it just made sense for me specifically for this package because I wanted to keep my messages (json files) in a separate and shared place for my monorepo. Since the messages are in a separate In any case, I still think I can only keep the messages there, and install next-intl everywhere I need it. Is this what you recommend me doing then? Thanks! |
Just to share how I am doing right now, most places in my next-js app I am importing the helpers from my internal package, and it's working 99% of the time. If you confirm it's best for me to remove next-intl re-exports from that package, I'll adjust it to install directly everywhere I need it. Thanks! |
Sure, sounds fine to me if this makes sense for your codebase!
Yep, that would be my recommendation! 🙂 I'm going to close this issue as it seems to have been resolved, hope this matches your understanding! |
IMPORTANT EDIT: I changed the title of this issue, as I have found out that the problem was not related to trpc. Just related to using Server Actions + Monorepo setup. I edited the issue description to best describe the problem as my latest advancement on this
Description
I have a file exporting a server action:
Whenver I import and call
getTranslations()
from my internal package, I get the error:NOTE: This issue is happening in production only (next start), and not in development (next dev)!
Verifications
Mandatory reproduction URL
https://github.com/dBianchii/next-intl-error-minimalreproduction
Reproduction description
I have tried to strip down as much as possible from my actual codebase and just show the current error.
Steps to reproduce:
pnpm i
pnpm build
cd apps/kdx
pnpm start
localhost:3000
apps/kdx/src/app/[locale]/actions/onboardingActions.ts
next start
Expected behaviour
It should not error when I call
await getTranslations()
from an exported package of my monorepo inside a server actionThe text was updated successfully, but these errors were encountered: