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

RangeError when generating individual pages from data #3289

Open
groenroos opened this issue May 21, 2024 · 0 comments
Open

RangeError when generating individual pages from data #3289

groenroos opened this issue May 21, 2024 · 0 comments

Comments

@groenroos
Copy link

Operating system

macOS 14.2.1

Eleventy

2.0.1

Describe the bug

Creating individual pages from data using the pagination technique started suddenly returning a RangeError:

[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] 1. Having trouble rendering njk template ./site/src/video/video.njk (via TemplateContentRenderError)
[11ty] 2. Having trouble compiling template ./site/src/video/video.njk (via TemplateContentCompileError)
[11ty] 3. (./site/src/video/video.njk)
[11ty]   RangeError: Maximum call stack size exceeded (via Template render error)
[11ty]
[11ty] Original error stack trace: Template render error: (./site/src/video/video.njk)
[11ty]   RangeError: Maximum call stack size exceeded
[11ty]     at Object._prettifyError (/node_modules/nunjucks/src/lib.js:32:11)
[11ty]     at Template.init (/node_modules/nunjucks/src/environment.js:416:19)
[11ty]     at Template.Obj (/node_modules/nunjucks/src/object.js:51:15)
[11ty]     at new Template (/node_modules/nunjucks/src/environment.js:390:18)
[11ty]     at Nunjucks.compile (/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:406:14)
[11ty]     at TemplateRender.getCompiledTemplate (/node_modules/@11ty/eleventy/src/TemplateRender.js:278:26)
[11ty]     at Template.compile (/node_modules/@11ty/eleventy/src/TemplateContent.js:362:42)
[11ty]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[11ty]     at async Template._render (/node_modules/@11ty/eleventy/src/TemplateContent.js:486:16)

This is similar to #498, but in my case, I'm not using macros or nested loops (or indeed any loops at all) in the template the error is complaining about - the same error happens even if the markup of the paginated template is empty.

Mitigation attempts

  • This seems to be closely related to the size of the data array, since this code worked fine prior to the size of the source data growing.

    • While debugging I noticed that truncating the array with .slice() before it reached Eleventy suppressed the error; in my case, only if the data contained more than ~200 items, this stack size error would begin to appear.
  • Interestingly, removing addAllPagesToCollections: true from the pagination object makes the error go away regardless of array length, and the pages build as normal; but this isn't desirable behaviour for me, as I do need the pages to be included in collections as well.

Reproduction steps

Template I'm using for generating pages using pagination:

---json
{
	"pagination": {
		"data": "videos",
		"size": 1,
		"alias": "video",
		"addAllPagesToCollections": true
	},
	"tags": "video",
	"eleventyComputed": {
		"title": "{{ video.title }}",
		"permalink": "video/{{ video.slug }}/"
	}
}
---

The videos data is an array of objects like so;

[
  {
    title: "Foo",
    slug: "foo"
  },
  ..
]

In my case, once the array started to contain 191 items, the error started to appear. The objects in my array contain additional metadata keys irrelevant to a minimal reproduction.

Expected behavior

The build should finish without errors and generate all the pages, regardless of the length of the data array

Reproduction URL

No response

Screenshots

No response

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

No branches or pull requests

1 participant