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

Pages with rewrite failing to load #2 #1044

Closed
thiras opened this issue Mar 8, 2021 · 2 comments
Closed

Pages with rewrite failing to load #2 #1044

thiras opened this issue Mar 8, 2021 · 2 comments

Comments

@thiras
Copy link

thiras commented Mar 8, 2021

The previous issue (#1031) has been closed because of the wrong reproducible example. But it's fixed and the example repository reproduces the bug consistently now.

Describe the bug

The pages with translation failed to load (500) if they have rewritten to a destination. This problem only occurs against a direct hit to the rewritten URL. Client-side navigation works totally fine.

Occurs in next-i18next version

8.1.0

Steps to reproduce

I've created a reproducible repo here; https://github.com/thiras/next-i18next-rewrite-bug Just deploy it on Vercel and hit /tr/hakkimizda directly (Turkish equivalent of /about)

Expected behaviour

Translations should work with the rewrites. Rewrites are the best option to handle slug translation so far.

Screenshots

Here is the vercel error output;

[GET] /tr/hakkimizda
03:03:30:65
Status:-1
Duration:498.90 ms
Init Duration: 153.21 ms
Memory Used:87 MB
ID:7sr9j-1615161809932-f1baf335c79f
User Agent:Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0
t Object.readdirSync (fs.js:1021:3)    at getAllNamespaces (/var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js:113:21)    at createConfig (/var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js:118:29)    at _callee$ (/var/task/node_modules/next-i18next/dist/commonjs/serverSideTranslations.js:105:53)    at tryCatch (/var/task/node_modules/regenerator-runtime/runtime.js:63:40)    at Generator.invoke [as _invoke] (/var/task/node_modules/regenerator-runtime/runtime.js:293:22)    at Generator.next (/var/task/node_modules/regenerator-runtime/runtime.js:118:21)    at asyncGeneratorStep (/var/task/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)    at _next (/var/task/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)    at processTicksAndRejections (internal/process/task_queues.js:93:5) {  errno: -2,  syscall: 'scandir',  path: '/var/task/public/locales/en'}2021-03-08T00:03:31.551Z	f7878e2d-ad85-4f03-8e02-e8badde3314d	ERROR	Error: ENOENT: no such file or directory, scandir '/var/task/public/locales/en'    at Object.readdirSync (fs.js:1021:3)    at getAllNamespaces (/var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js:113:21)    at createConfig (/var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js:118:29)    at _callee$ (/var/task/node_modules/next-i18next/dist/commonjs/serverSideTranslations.js:105:53)    at tryCatch (/var/task/node_modules/regenerator-runtime/runtime.js:63:40)    at Generator.invoke [as _invoke] (/var/task/node_modules/regenerator-runtime/runtime.js:293:22)    at Generator.next (/var/task/node_modules/regenerator-runtime/runtime.js:118:21)    at asyncGeneratorStep (/var/task/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)    at _next (/var/task/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)    at processTicksAndRejections (internal/process/task_queues.js:93:5) {  errno: -2,  syscall: 'scandir',  path: '/var/task/public/locales/en'}2021-03-08T00:03:31.551Z	f7878e2d-ad85-4f03-8e02-e8badde3314d	ERROR	Unhandled Promise Rejection 	{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: ENOENT: no such file or directory, scandir '/var/task/public/locales/en'","reason":{"errorType":"Error","errorMessage":"ENOENT: no such file or directory, scandir '/var/task/public/locales/en'","errno":-2,"syscall":"scandir","path":"/var/task/public/locales/en","stack":["Error: ENOENT: no such file or directory, scandir '/var/task/public/locales/en'","    at Object.readdirSync (fs.js:1021:3)","    at getAllNamespaces (/var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js:113:21)","    at createConfig (/var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js:118:29)","    at _callee$ (/var/task/node_modules/next-i18next/dist/commonjs/serverSideTranslations.js:105:53)","    at tryCatch (/var/task/node_modules/regenerator-runtime/runtime.js:63:40)","    at Generator.invoke [as _invoke] (/var/task/node_modules/regenerator-runtime/runtime.js:293:22)","    at Generator.next (/var/task/node_modules/regenerator-runtime/runtime.js:118:21)","    at asyncGeneratorStep (/var/task/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)","    at _next (/var/task/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)","    at processTicksAndRejections (internal/process/task_queues.js:93:5)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: Error: ENOENT: no such file or directory, scandir '/var/task/public/locales/en'","    at process.<anonymous> (/var/runtime/index.js:35:15)","    at process.emit (events.js:327:22)","    at processPromiseRejections (internal/process/promises.js:245:33)","    at processTicksAndRejections (internal/process/task_queues.js:94:32)"]}Unknown application error occurred

OS (please complete the following information)

  • Device: Dell 7577 with Ubuntu 20.04
  • Browser: Firefox 86.0

Additional context

The example repo has deployed at https://next-i18next-rewrite-bug.vercel.app

Original page; https://next-i18next-rewrite-bug.vercel.app/about
Broken page with a rewrite to the original page; https://next-i18next-rewrite-bug.vercel.app/tr/hakkimizda

The Error has also attached as a screenshot from Vercel below.

Screenshot from 2021-03-08 15-48-11

@isaachinman
Copy link
Contributor

You will need to use path.resolve to instruct the Vercel platform to keep your public/locales dir. Here is a relevant comment. Good luck!

@thiras
Copy link
Author

thiras commented Mar 8, 2021

Omg finally. I was going to mad while trying to figure out the problem. Thank you very much.

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

2 participants