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

Bug with next-i18next and deployment on Vercel #40130

Closed
1 task done
serGlazkov opened this issue Aug 31, 2022 · 13 comments · Fixed by #40164
Closed
1 task done

Bug with next-i18next and deployment on Vercel #40130

serGlazkov opened this issue Aug 31, 2022 · 13 comments · Fixed by #40164
Labels
bug Issue was opened via the bug report template.

Comments

@serGlazkov
Copy link

serGlazkov commented Aug 31, 2022

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

"next": "12.2.5", // Also tested on 12.2.6-canary.7 and 12.1.6
"next-i18next": "12.0.0", // Also tested on 10.5.0
"react": "18.2.0", // Also tested on 17.0.2
"react-dom": "18.2.0" // Also tested on 17.0.2

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

Vercel

Describe the Bug

Context

We encountered a bug around next-i18next that resulted in serverless crashes for catch-all routes. We noticed this bug for the first time Monday around 14:00 CET and think it is potentially related with a change in the serverless runtime/filestructure as older deployments that used to work stoped working when redeploying.

Some other people also seemed to have encountered the same bug. See also here:

What we tried

So we upgraded our versions of next and next-i18next (like some of the other people did).
With the most recent next.js and next-i18next versions translations seem to work only in very specific cases.

We created a minimal replicable deployment (Repo) where we prebuild two pages via putting them in getStaticPaths:

Both pages do not use translations when opening them directly.

However, when first navigating to the index.js and then clicking on of the links the two pages use proper translation.

Note: The translations will break upon refresh.

Setup Description

  • catch all route in pages folder
  • page set to static site generation
  • default locale is set
  • incremental static regeneration is on

Expected Behavior

working Translations

Link to reproduction

https://github.com/everdropde/ed-i18n-bug

To Reproduce

  1. Clone the Repo and deploy it to Vercel
  2. Click any link on page
@serGlazkov serGlazkov added the bug Issue was opened via the bug report template. label Aug 31, 2022
@ellisio
Copy link

ellisio commented Aug 31, 2022

We ran into this as well, as we were on next-i18next@8.1.1 when this broke. We resolved this by updating to next-i18next@12.0.0. Then we had to make the following updates:

next-18next.config.js:

const path = require('path');

module.exports = {
  debug: process.env.NODE_ENV === 'development',
  i18n: {
    defaultLocale: 'en',
    locales: ['en', 'es'],
  },
  localePath: path.resolve('./public/locales'),
  reloadOnPrerender: process.env.NODE_ENV === 'development',
};

pages/_document.js:

import i18nextConfig from '../next-i18next.config';

export default class MyDocument extends Document {
  render() {
    const currentLocale =
      // eslint-disable-next-line no-underscore-dangle
      this.props.__NEXT_DATA__.locale || i18nextConfig.i18n.defaultLocale;

    return (
      <Html lang={currentLocale}>
        <!-- our document code -->
      </Html>
    );
  }
}

We are on next@10.0.2 so the version of next does not seem to be the issue; it is specifically next-i18next.

@swarnava
Copy link
Member

Hi,

Can you set following env variable and let us know if you can reproduce?

VERCEL_CLI_VERSION=vercel@28.1.4

@FBosler
Copy link

FBosler commented Aug 31, 2022

@swarnava yes, we still can reproduce. My hunch is that it's related to vercel/nft#304
Update: Alright, we cant reproduce if we include!
localePath: path.resolve('./public/locales'),

@tetsupanda
Copy link

tetsupanda commented Aug 31, 2022

For my org, dropping the vercel cli version to vercel@28.1.4 worked. We have a similar config of next-i18next, as stated above too:

  i18n: {
    defaultLocale: 'en',
    locales: ['en', 'es'],
  },
  localePath: path.resolve('./public/locales')

Will continue to monitor for any new CLI version releases though.

For reference we are on next@10.0.2 and next-i18next@8.2.0

Thank you @swarnava for the call out of dropping the CLI version!

@swarnava
Copy link
Member

I am working with the team to prepare a fix for this. Appreciate your patience everyone!

@swarnava
Copy link
Member

swarnava commented Aug 31, 2022

Hi, could you confirm if you have outputFileTracing disabled ? If you have it enabled and using latest version of Next.js then this should work with latest CLI version

@ellisio
Copy link

ellisio commented Aug 31, 2022

@swarnava Unrelated to fixing this, should there perhaps be a notice put on https://www.vercel-status.com/? I know that when we first were impacted by this that was the first stop for us to see if there was a Vercel issue.

I ask this because if anyone tries to redeploy an old version, that version breaks as well so it is impossible to rollback. If this is a production website/app, that ends up being an outage for that customer.

@serGlazkov
Copy link
Author

@swarnava yes, if you have outputFileTracing: true then it works with latest CLI version

@swarnava
Copy link
Member

In that case, we will likely going to stay with the current approach. Ideally, you should NOT be using outputFileTracing: false because then you will lose control of Next.js version and are subject to platform changes. The default outputFileTracing: true is safest.

@serGlazkov
Copy link
Author

@swarnava We disabled it previously because #30561 (comment)

@FBosler
Copy link

FBosler commented Sep 1, 2022

@swarnava Unrelated to fixing this, should there perhaps be a notice put on https://www.vercel-status.com/? I know that when we first were impacted by this that was the first stop for us to see if there was a Vercel issue.

I ask this because if anyone tries to redeploy an old version, that version breaks as well so it is impossible to rollback. If this is a production website/app, that ends up being an outage for that customer.

Couldn't agree more, I don't think its good practice to simply roll out potentially breaking changes without informing your customers about it. There was no indication on the status page, that a new Vercel CLI had been rolled out to production (would have helped us speed up the bug hunting process massively).

ijjk pushed a commit that referenced this issue Sep 1, 2022
@swarnava
Copy link
Member

swarnava commented Sep 3, 2022

btw, if you are using VERCEL_CLI_VERSION to pin version number, please make sure you remove it to ensure have latest CLI updates.

atilafassina pushed a commit to atilafassina/next.js that referenced this issue Sep 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Oct 3, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants