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

Maximum call stack size exceeded with some settings #493

Assignees
Labels

Comments

@thib3113
Copy link

thib3113 commented Mar 4, 2022

I think I found a bug,
I'm using version 0.14.1 .

I'm using the options :

retryInDefaultLocale = true;
syncFiles: true,

So when I translate :

  • i18nTranslate => call translate
  • translate see (!skipSyncToAllFiles && syncFiles) === true => call syncToAllFiles
  • syncToAllFiles => call translate with skipSyncToAllFiles = true
  • translate go to here (same here) => call translate file without skipSyncToAllFiles
  • translate see (!skipSyncToAllFiles && syncFiles) === true => call syncToAllFiles (and then, restart the loop) .

Maybe passing syncToAllFiles here and here, can be a quick fix

@mashpie
Copy link
Owner

mashpie commented Mar 4, 2022

would you be able to setup a minimal reproduction repository?

@thib3113
Copy link
Author

thib3113 commented Mar 4, 2022

@mashpie here is it : https://github.com/thib3113/i18n-493-issue .

But, it's mostly :

const { I18n } = require("i18n");
const path = require("path");

const i18n = new I18n({
    locales: ["en", "de"],
    directory: path.join(__dirname, "locales"),
    defaultLocale: "en",
    retryInDefaultLocale: true,
    syncFiles: true,
});

i18n.__("test");

Setting syncFiles and retryInDefaultLocale in the same times that produce the bug .

@mashpie mashpie self-assigned this Mar 4, 2022
@mashpie
Copy link
Owner

mashpie commented Mar 4, 2022

Thanks, will look into it over weekend probably

@mashpie mashpie added the bug label Mar 5, 2022
@mashpie mashpie closed this as completed in 1d956f3 Mar 5, 2022
@mashpie
Copy link
Owner

mashpie commented Mar 5, 2022

Thank you @thib3113 for reporting and analysing. Your guess for a fix was also perfectly right. I've just added tests to cover your issue.

A new version 0.14.2 should be released within minutes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment