Environment
- Nuxt /
@nuxt/kit 4.5.1 (repro). Kit 4.5.0 often survives because it used klona (lite).
- Relevant change:
loadNuxtConfig does klona(resolved.config) via klona/full (no cycle detection).
Reproduction
// locales.json — a JSON array
// [{ "code": "en" }, { "code": "de" }]
// nuxt.config.ts
import locales from './locales.json'
export default defineNuxtConfig({
// any module option that holds the array is enough; i18n shown as real-world case
i18n: { locales },
})
Then nuxt prepare → Maximum call stack size exceeded in klona/full.
Control: locales: locales.map((l) => ({ ...l })) → OK.
Minimal jiti check (Nuxt loads config with interopDefault: true):
import { createJiti } from 'jiti'
const jiti = createJiti(import.meta.url, { interopDefault: true })
const mod = jiti('./locales.json')
Array.isArray(mod) // true
mod.default === mod // true ← cycle
Native import … with { type: 'json' } does not add that default.
Describe the bug
- jiti +
interopDefault attaches default to a JSON array module pointing at itself.
- Kit 4.5.1 clones the full resolved config with
klona/full, which walks .default forever.
- Crash happens in
loadNuxtConfig before any module setup, so modules cannot sanitize in time.
Path from a patched depth-limited klona looked like: .i18n.locales.default.default…default.0.
Suggested directions
- Make config clone cycle-safe (
WeakSet / use lite where full isn’t needed), and/or
- Avoid attaching
default onto array exports in the jiti path used for nuxt.config.
Workaround for apps: shallow-clone the array before putting it in config.
Seen with nuxt-i18n-micro i18n.locales from a JSON array import; module-side normalize only helps after a successful load.
Environment
@nuxt/kit4.5.1 (repro). Kit 4.5.0 often survives because it usedklona(lite).loadNuxtConfigdoesklona(resolved.config)viaklona/full(no cycle detection).Reproduction
Then
nuxt prepare→Maximum call stack size exceededinklona/full.Control:
locales: locales.map((l) => ({ ...l }))→ OK.Minimal jiti check (Nuxt loads config with
interopDefault: true):Native
import … with { type: 'json' }does not add thatdefault.Describe the bug
interopDefaultattachesdefaultto a JSON array module pointing at itself.klona/full, which walks.defaultforever.loadNuxtConfigbefore any modulesetup, so modules cannot sanitize in time.Path from a patched depth-limited klona looked like:
.i18n.locales.default.default…default.0.Suggested directions
WeakSet/ use lite where full isn’t needed), and/ordefaultonto array exports in the jiti path used fornuxt.config.Workaround for apps: shallow-clone the array before putting it in config.
Seen with nuxt-i18n-micro
i18n.localesfrom a JSON array import; module-side normalize only helps after a successful load.