Skip to content
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

Translations failing when page is idle for couple of hours #2267

Open
PreethiVS21 opened this issue Mar 28, 2024 · 11 comments
Open

Translations failing when page is idle for couple of hours #2267

PreethiVS21 opened this issue Mar 28, 2024 · 11 comments

Comments

@PreethiVS21
Copy link

PreethiVS21 commented Mar 28, 2024

🐛 Bug Report

in next-i18next version 13.2.2, When translations are rendered using getServerSideProps (next 13.5-pages router) , translations doesn't happen after couple of hours. I can only see key names .

To Reproduce

next-i18next.config.js

const path = require('path');
module.exports = {
  debug: false,
  i18n: {
    defaultLocale: "en",
    locales: ["en", "es"],
  },
  localePath:
    typeof window === 'undefined'
      ? path.resolve('./public/locales')
      : '/locales'
};

index.tsx

export const getServerSideProps: GetServerSideProps<Props> = async ({
  locale,
})=>{

  return {
    props: {
      ...(await serverSideTranslations(locale ?? 'en', [
        'common',
        'randomns'
      ]))
    }
  };
}

Expected behavior

Translations shouldn't fail intermittently

Your Environment

"i18next": "^22.4.13",
"next": "^13.5.6",(pages router)
"next-i18next": "^13.2.2",
@adrai
Copy link
Member

adrai commented Mar 28, 2024

Hearing this for the first time...
Maybe a problem of your deployment environment?
Or is this reproducible also locally?
Please provide more information.

@PreethiVS21
Copy link
Author

Yes, I can reproduce it locally. Similar comment was addressed here. Can you confirm if this is needed whenever we need to get translations from getServerSideProps
vercel/next.js#46730 (comment)

@adrai
Copy link
Member

adrai commented Mar 28, 2024

seems the way Next.js handles this... yes

@Sarawut-keng
Copy link

Sarawut-keng commented Apr 3, 2024

@PreethiVS21 Have you figured out how to fix it? I have also encountered this issue.
I have utilized Page Router, and below are the versions of the packages I am currently using:

"i18next": "^23.8.2",
"next-i18next": "^15.2.0",
"next": "^13.5.6"

@jgregory-apogee
Copy link

I've found I can reproduce this locally fairly easily. In our case, we are using a custom Docker image. Simply rebuilding the image and redeploying it is enough to break the translations.

Steps:

  1. Deploy the app in prod mode and open any page.
  2. Rebuild / redeploy the image.
  3. Soft-navigate from the already-opened page to another page. Translations will be broken.

I can see that Next is fetching a translations file on every page transition. For instance, every time I navigate to Page A, it will fetch /_next/data/tfbRnBfT3Y6OXf7Afbrm1/en/PageA/6632778e658b8005459f8503.json, and every time I go to Page B, it will fetch /_next/data/tfbRnBfT3Y6OXf7Afbrm1/en/PageB/99125246-21fc-4742-876c-e7d3b9a52bcc.json. But after a redeploy, those two URLs return an empty translation list: {}. Presumably this is because the Next BUILD_ID has changed. If I do a full reload, the pages fetch slightly different URLs, like: /_next/data/eCtPEywIx-3IoSgG-JHVF/en/PageA/6632778e658b8005459f8503.json. (Note that the old BUILD_ID tfbRnBfT3Y6OXf7Afbrm1 has been replaced with eCtPEywIx-3IoSgG-JHVF).

Anyways, it seems I need a way to detect that there's a new BUILD_ID in play and force next to do a full-page-load transition.

@BrilliantDecision
Copy link

BrilliantDecision commented Jun 25, 2024

@PreethiVS21 @Sarawut-keng any updates guys? same issue on the same next version 13.5.6 (pages router) @adrai @jgregory-apogee

@BrilliantDecision
Copy link

@adrai getServerSideProps totally doesnt work after couple of hours, its ok with getStaticProps

@adrai
Copy link
Member

adrai commented Jul 3, 2024

@adrai getServerSideProps totally doesnt work after couple of hours, its ok with getStaticProps

If that's the case you may ask the Next.js team...

@Sarawut-keng
Copy link

@BrilliantDecision after reviewing the case, I have figured out that @jgregory-apogee ’s comment was correct. After my CD re-deployment, the language broke. I am not sure if this occurs only on the page router. Right now, we do not have the best solution yet. We have just briefed users that we have updated to a new version and that they need to refresh the screen.

@BrilliantDecision
Copy link

@Sarawut-keng and how do you implement this notification, what do you use for this? how do you understand that you need to refresh the page? some error catcher?

@mehmetyilmaz001
Copy link

We have the exact same problem here. i18n store is empty on after some deployments even the translation files are exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants