-
Notifications
You must be signed in to change notification settings - Fork 469
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
RangeError: Maximum call stack size exceeded on any version after 6.17.0 #1075
RangeError: Maximum call stack size exceeded on any version after 6.17.0 #1075
Comments
Can you show the full source code of that component? |
sure, here you have
|
Sorry but need more information.
If you could log the Ideally, you would create a repo that reproduces as that would save a lot of time in trying to figure this one out. |
@PolarWooolf, when is the error thrown? I changed the Vuetify v-select to a radio version, and everything is fine now. |
Thanks for that information. Should be very helpful in reproducing and fixing. It looks like you are also using i18n block in that component because that's when extend is called. |
Ensure that we always clone the original "locales" when assigning to "$i18n.locales" so that if the object is made reactive by the user, we don't attempt to clone that. Resolves #1075
Created a fix in #1090 So it's enough to make the |
This issue is still happening in v8.27.2 If you run twice
Then msg gets reactive after the first call, and the second call results in an error |
This is an API provided by https://github.com/kazupon/vue-i18n so you could report it there. But I do think that it should be possible to avoid doing that on your side as a workaround. Is there any good reason for assigning the same messages object twice? FYI @kazupon |
Indeed, this is the wrong repo, sorry, I just came here from googling this issue and didn't check the url It's weird because I've been trying to get it to reproduce on codesandbox but I just can't, it's happening on a large codebase and I'm thinking it's only happening with a weird combo of things I was originally just switching locales multiple times and the loader wasn't checking if the locale had already been loaded (it's lazy loading the locale from a json file) import axios from 'rewart-frontend-library/src/plugins/axios';
import Vue from 'vue';
import VueI18n from 'vue-i18n';
import vuetify from '@/plugins/vuetify';
Vue.use(VueI18n);
function loadLocaleMessages(locale) {
return Promise.all([
import(
/* webpackChunkName: "app-locale-[request]" */
/* webpackInclude: /(en|hu).json$/ */
/* webpackMode: "lazy" */
/* webpackPreload: true */
`@/locales/${locale}.json`),
import(
/* webpackChunkName: "vuetify-locale-[request]" */
/* webpackInclude: /(en|hu).js$/ */
/* webpackMode: "lazy" */
/* webpackPreload: true */
`vuetify/lib/locale/${locale}.js`).then((v) => v.default),
]).then(([msg, vuetify]) => i18n.setLocaleMessage(locale, {...msg, $vuetify: vuetify})); // Error happening here
}
let fallbackLoaded = false;
let fallbackLoading = false;
const i18n = new VueI18n({
locale: null,
fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en',
messages: {},
silentFallbackWarn: true,
missing(locale) {
if (!fallbackLoaded && !fallbackLoading && locale !== i18n.fallbackLocale) {
fallbackLoading = true;
loadLocaleMessages(i18n.fallbackLocale).then(() => fallbackLoaded = true);
}
},
});
export const switchLocale = (locale = process.env.VUE_APP_I18N_LOCALE || 'en') => {
const lang = locale.slice(0, 2);
// If the same language
if (i18n.locale === lang) {
return Promise.resolve();
}
return loadLocaleMessages(lang).then(() => {
axios.defaults.headers.common['Accept-Language'] = lang;
document.querySelector('html').setAttribute('lang', lang);
i18n.locale = lang;
vuetify.framework.lang.current = locale;
});
};
export default i18n; And so once the same locale gets loaded again this error happens (maybe it has to do with webpack modules) As a workaround I indeed just keep a variable of the loaded locales to avoid loading the same one multiple times |
Version
nuxt-i18n: any version after 6.17.0
nuxt: 2.14.2 and 2.15.2
Nuxt-i18n configuration
inside a component we have:
methods: {
async switLang(lang) {
await this.$i18n.setLocale(lang)
}
}
I'm just using this.$i18n.setLocale(language);
and it works 100% fine only IF "nuxt-i18n": "^6.17.0",
any other version after that drops the error. Maybe not the first time but randomly after repeating some times the lang switching
I use no_prefix strategy
any help?
Thanks
The text was updated successfully, but these errors were encountered: