Environment
- OS: macOS 15.4 (Darwin 25.4.0 arm64)
- Node: v24.13.0
- Nuxt: 4.4.2
- @nuxt/content: 3.12.0
- nuxt-studio: 1.6.0
Version
3.12.0
Reproduction
The bug is in the compiled source at dist/module.mjs and can be verified by inspecting the /__preview.json endpoint output. Steps:
- Create a Nuxt 4 project with
@nuxt/content v3 and nuxt-studio
- Define any content collections in
content.config.ts
- Deploy with SSR and navigate to
/__preview.json
- Observe that the
info collection has "source": [] instead of being excluded or having source omitted
Description
The internal info collection created by resolveCollections() has source: void 0 (line 2405 of dist/module.mjs):
collections.info = {
type: "data",
source: void 0,
schema: infoStandardSchema,
// ...
};
The previewTemplate() function (line 1701) serializes this into source: []:
source: collection.source?.filter((source) => source.repository ? void 0 : collection.source) || [],
Since undefined?.filter(...) evaluates to undefined, the || [] fallback kicks in, producing source: [] in the serialized output.
This causes downstream crashes in nuxt-studio, which iterates all collections and accesses source[0].include / source[0].prefix without guarding against empty arrays — resulting in TypeError: Cannot read properties of undefined (reading 'include').
See also: nuxt-content/nuxt-studio#425
Suggested fix
Either exclude collections without source from the preview payload:
// In previewTemplate, skip the info collection
if (!collection.source) return acc;
Or use ?? instead of || to preserve the distinction:
source: collection.source?.filter((source) => source.repository ? void 0 : collection.source) ?? undefined,
(With ?? undefined, JSON.stringify will omit the key entirely.)
I'm happy to submit a PR if you'd prefer one approach over the other.
Additional context
The nuxt-studio side also lacks null guards (tracked in nuxt-content/nuxt-studio#425), but the root cause is the serialization here — source: void 0 should not become source: [] in the preview payload.
Logs
TypeError: Cannot read properties of undefined (reading 'include')
at parseSourceBase (source.js)
at Array.map
at async Object.list
at async Object.load (main-CUjoLU7k.js)
Environment
Version
3.12.0
Reproduction
The bug is in the compiled source at
dist/module.mjsand can be verified by inspecting the/__preview.jsonendpoint output. Steps:@nuxt/contentv3 andnuxt-studiocontent.config.ts/__preview.jsoninfocollection has"source": []instead of being excluded or havingsourceomittedDescription
The internal
infocollection created byresolveCollections()hassource: void 0(line 2405 ofdist/module.mjs):The
previewTemplate()function (line 1701) serializes this intosource: []:Since
undefined?.filter(...)evaluates toundefined, the|| []fallback kicks in, producingsource: []in the serialized output.This causes downstream crashes in
nuxt-studio, which iterates all collections and accessessource[0].include/source[0].prefixwithout guarding against empty arrays — resulting inTypeError: Cannot read properties of undefined (reading 'include').See also: nuxt-content/nuxt-studio#425
Suggested fix
Either exclude collections without source from the preview payload:
Or use
??instead of||to preserve the distinction:(With
?? undefined,JSON.stringifywill omit the key entirely.)I'm happy to submit a PR if you'd prefer one approach over the other.
Additional context
The
nuxt-studioside also lacks null guards (tracked in nuxt-content/nuxt-studio#425), but the root cause is the serialization here —source: void 0should not becomesource: []in the preview payload.Logs