nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.71k stars 478 forks source link

Maximum call stack size exceeded when use nuxt@3.11.1 #2892

Closed ausir0726 closed 6 months ago

ausir0726 commented 6 months ago

Environment


Reproduction

a empty nuxt 3 starter project install nuxt-i18n and console.log(locale)

<script setup>
const { locale } = useI18n();
console.log(locale);
</script>

Describe the bug

when I use nuxt@3.11.1 I console.log(locale) the page crash ( Maximum call stack size exceeded )

it's works nuxt@3.10

Additional context

at Array.map ()
at stringify (/C:/Users/ausir/test/nuxt-pppp/node_modules/.pnpm/@nuxt+devalue@2.0.2/node_modules/@nuxt/devalue/dist/devalue.mjs:114:39)
at /C:/Users/ausir/test/nuxt-pppp/node_modules/.pnpm/@nuxt+devalue@2.0.2/node_modules/@nuxt/devalue/dist/devalue.mjs:91:58
at Array.map ()
at stringify (/C:/Users/ausir/test/nuxt-pppp/node_modules/.pnpm/@nuxt+devalue@2.0.2/node_modules/@nuxt/devalue/dist/devalue.mjs:91:31)
at Array.map ()
at stringify (/C:/Users/ausir/test/nuxt-pppp/node_modules/.pnpm/@nuxt+devalue@2.0.2/node_modules/@nuxt/devalue/dist/devalue.mjs:96:50)
at /C:/Users/ausir/test/nuxt-pppp/node_modules/.pnpm/@nuxt+devalue@2.0.2/node_modules/@nuxt/devalue/dist/devalue.mjs:91:58
at Array.map ()

Logs

No response

github-actions[bot] commented 6 months ago

Would you be able to provide a reproduction? 🙏

More info ### Why do I need to provide a reproduction? Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making. ### What will happen? If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect. If `needs reproduction` labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it. ### How can I create a reproduction? We have a couple of templates for starting with a minimal reproduction: 👉 [Reproduction starter (v8 and higher)](https://stackblitz.com/fork/github/BobbieGoede/nuxt-i18n-starter/tree/v8) 👉 [Reproduction starter (edge)](https://stackblitz.com/fork/github/BobbieGoede/nuxt-i18n-starter/tree/edge) A public GitHub repository is also perfect. 👌 Please ensure that the reproduction is as **minimal** as possible. See more details [in our guide](https://nuxt.com/docs/community/reporting-bugs/#create-a-minimal-reproduction). You might also find these other articles interesting and/or helpful: - [The Importance of Reproductions](https://antfu.me/posts/why-reproductions-are-required) - [How to Generate a Minimal, Complete, and Verifiable Example](https://stackoverflow.com/help/mcve)
ausir0726 commented 6 months ago

I am unable to reproduce the issue in stackblitz, but it does occur on my WIN/MAC OS. Still trying to figure out the problem.

ausir0726 commented 6 months ago

@BobbieGoede

Finally, I was able to reproduce the error in Codesandbox. It seems that the error can only be reproduced on node v20 (but in my local env, I use node v18 got same error)

https://codesandbox.io/p/devbox/fancy-wave-7tjy7r

------------------------------
- Operating System: Linux
- Node Version:     v20.9.0
- Nuxt Version:     3.11.1
- CLI Version:      3.11.1
- Nitro Version:    2.9.6
- Package Manager:  npm@9.8.1
- Builder:          -
- User Config:      devtools, modules
- Runtime Modules:  @nuxtjs/i18n@8.3.0
- Build Modules:    -
------------------------------
ausir0726 commented 6 months ago

Additional information

Everything is normal when using 3.10.3.

<ref *1> ComputedRefImpl {
  getter: [Function: get],
  _setter: [Function: set],
  dep: undefined,
  __v_isRef: true,
  __v_isReadonly: false,
  effect: ReactiveEffect {
    fn: [Function (anonymous)],
    trigger: [Function (anonymous)],
    scheduler: undefined,
    active: true,
    deps: [ [Map] ],
    _dirtyLevel: 0,
    _trackId: 1,
    _runnings: 0,
    _shouldSchedule: false,
    _depsLength: 1,
    computed: [Circular *1]
  },
  _cacheable: true,
  _value: 'en-US'
}

When using 3.11.0, there are no error messages displayed (have WARN), but the screen does not render (only displaying NUXT LOGO)

<ref *1> ComputedRefImpl {
  getter: [Function: get],
  _setter: [Function: set],
  dep: undefined,
  __v_isRef: true,
  __v_isReadonly: false,
  effect:
   ReactiveEffect {
     fn: [Function (anonymous)],
     trigger: [Function (anonymous)],
     scheduler: undefined,
     active: true,
     deps: [ [Map] ],
     _dirtyLevel: 0,
     _trackId: 1,
     _runnings: 0,
     _shouldSchedule: false,
     _depsLength: 1,
     computed: [Circular *1] },
  _cacheable: true,
  _value: 'en-US' }

 WARN  Cannot stringify arbitrary non-POJOs ComputedRefImpl

When using 3.11.1, an error occurs.

<ref *1> ComputedRefImpl {
  getter: [Function: get],
  _setter: [Function: set],
  dep: undefined,
  __v_isRef: true,
  __v_isReadonly: false,
  effect:
   ReactiveEffect {
     fn: [Function (anonymous)],
     trigger: [Function (anonymous)],
     scheduler: undefined,
     active: true,
     deps: [ [Map] ],
     _dirtyLevel: 0,
     _trackId: 1,
     _runnings: 0,
     _shouldSchedule: false,
     _depsLength: 1,
     computed: [Circular *1] },
  _cacheable: true,
  _value: 'en-US' }

 WARN  Cannot stringify arbitrary non-POJOs ComputedRefImpl

 ERROR  [nuxt] [request error] [unhandled] [500] Maximum call stack size exceeded
  at Map.has (<anonymous>)
  at stringify (/C:/Users/ausir/test/nuxt-pppp/node_modules/@nuxt/devalue/dist/devalue.mjs:74:15)
  at /C:/Users/ausir/test/nuxt-pppp/node_modules/@nuxt/devalue/dist/devalue.mjs:91:58
  at Array.map (<anonymous>)
  at stringify (/C:/Users/ausir/test/nuxt-pppp/node_modules/@nuxt/devalue/dist/devalue.mjs:91:31)
  at /C:/Users/ausir/test/nuxt-pppp/node_modules/@nuxt/devalue/dist/devalue.mjs:114:71
  at Array.map (<anonymous>)
  at stringify (/C:/Users/ausir/test/nuxt-pppp/node_modules/@nuxt/devalue/dist/devalue.mjs:114:39)
  at /C:/Users/ausir/test/nuxt-pppp/node_modules/@nuxt/devalue/dist/devalue.mjs:91:58
  at Array.map (<anonymous>)
BobbieGoede commented 6 months ago

It looks like this is related to the devLogs feature, it starts working again when disabling it by adding features: { devLogs: false } do the Nuxt config.

Not sure if this is necessarily an issue caused by this module or caused by the way values are stringified by this feature 🤔 Will have to check if there's an existing issue on the Nuxt repo later.

ausir0726 commented 6 months ago

According to https://github.com/nuxt/nuxt/issues/26605#issuecomment-2033691870

Should be fixed via https://github.com/nuxt/nuxt/pull/26503 on nightly