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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encountering Error: ENOENT: no such file or directory, scandir 'XXX' occasionally #2244

Open
yuuk opened this issue Dec 25, 2023 · 0 comments
Labels

Comments

@yuuk
Copy link

yuuk commented Dec 25, 2023

馃悰 Bug Report

Our project is undergoing pressure testing in docker container by JMeter, when the concurrent count is high, the following error will occur, But the directory is actually exist.

2023-12-25 07:47 +00:00: Error: ENOENT: no such file or directory, scandir '/app/packages/eshop/public/locales/cn'
    at Object.readdirSync (node:fs:1405:3)
    at getLocaleNamespaces (/app/node_modules/next-i18next/dist/commonjs/config/createConfig.js:214:16)
    at /app/node_modules/next-i18next/dist/commonjs/config/createConfig.js:231:20
    at Array.map (<anonymous>)
    at getNamespaces (/app/node_modules/next-i18next/dist/commonjs/config/createConfig.js:230:44)
    at createConfig (/app/node_modules/next-i18next/dist/commonjs/config/createConfig.js:271:29)
    at _callee$ (/app/node_modules/next-i18next/dist/commonjs/serverSideTranslations.js:201:53)
    at tryCatch (/app/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:44:17)
    at Generator.<anonymous> (/app/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:125:22)
    at Generator.next (/app/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:69:21) {
  errno: -2,
  syscall: 'scandir',
  path: '/app/packages/eshop/public/locales/cn'
}
2023-12-25 07:46 +00:00: Error: ENOENT: no such file or directory, scandir '/app/packages/eshop/public/locales/cn'
    at Object.readdirSync (node:fs:1405:3)
    at getLocaleNamespaces (/app/node_modules/next-i18next/dist/commonjs/serverSideTranslations.js:241:37)
    at /app/node_modules/next-i18next/dist/commonjs/serverSideTranslations.js:247:22
    at Array.map (<anonymous>)
    at _callee$ (/app/node_modules/next-i18next/dist/commonjs/serverSideTranslations.js:246:64)
    at tryCatch (/app/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:44:17)
    at Generator.<anonymous> (/app/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:125:22)
    at Generator.next (/app/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:69:21)
    at asyncGeneratorStep (/app/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (/app/node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9) {
  errno: -2,
  syscall: 'scandir',
  path: '/app/packages/eshop/public/locales/cn'
}

Here is the PT report could show the relationship between concurrent count and error count. The more concurrent count, the more error count.

50-3min
100-3min

I tried to invoke a large number of fs.readdirSync to read the directory, it didn't occur the error.

Maybe this is not next-i18next's problem, but I have no clue...

To Reproduce

next-i18next.config.js

const path = require('path');

module.exports = {
    i18n: {
        defaultLocale: 'none',
        locales: ['en', 'cn', 'tc', 'jp', 'it', 'fr', 'kr', 'none'],
    },
    localeExtension: 'json',
    defaultNS: 'common',
    localePath: path.resolve(__dirname, 'public/locales'),
    reloadOnPrerender: process.env.NODE_ENV === 'development',
};

PM2 config

const path = require('path');

module.exports = {
    apps: [
        {
            ...
            script: path.resolve(__dirname, './start.js'),
            cwd: path.resolve(__dirname),
            watch: false,
            watch_delay: 1000,
            ignore_watch: ['node_modules'],
            instances: 'max',
            exec_mode: 'cluster',
            ...
        },
    ],
};

It's not easy to reproduce, unless use high concurrent request.

Expected behavior

Do not report errors

Your Environment

  • runtime version: node v16.16.0, next v12.2.0
  • i18next version: 21.10.0
  • os: Linux
  • next-i18next: 11.3.0
@yuuk yuuk changed the title Encontering Error: ENOENT: no such file or directory, scandir 'XXX' occasionally Encountering Error: ENOENT: no such file or directory, scandir 'XXX' occasionally Dec 25, 2023
@adrai adrai added the stale label Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants