Skip to content

3.1.2-beta.2 regression: 11ty.js file breaks subsequent renders with "Problem writing Eleventy templates: templateRender has not yet initialized" #3870

Closed
@chriskirknielsen

Description

@chriskirknielsen

Operating system

macOs Sequoia 15.1

Eleventy

3.1.2-beta.2

Describe the bug

Hello! I installed the latest beta and I am running into an intermittent issue on the same file. I tested 3.1.2-beta.1 and the issue does not occur. EDIT: Also occurs with 3.1.2-beta.1. Does not occur on stable 3.1.1.

This is my only 11ty.js file, and I use it as a "database" for my search, outputting a JSON file. As such, it leverages the all collection, but that was a red herring and I have managed to replicate the issue with a very simple file:
search.11ty.js

export default class {
	data() {
		return {
			permalink: '/search.json',
			layout: false,
			eleventyExcludeFromCollections: true,
		};
	}

	async render(data) {
		return '[]';
	}
}

I encounter this on subsequent builds, here is my command:

npx @11ty/eleventy --serve --quiet --incremental

It does not occur on the first build, and doesn't occur on every change, but if I hit Cmd+S on my .eleventy.js file to cause a file change to be detected, then the error is consistent. Ironically enough, if I do the same Cmd+S operation on the search.11ty.js file, the build works.

I don't have a sample project but I hope this is enough to go off of, and if not, let me know and I'll try to get a reduced test case available.

Thanks!

Reproduction steps

  1. Create a new 11ty.js file
  2. Set its data to an permalink, exclude it from the collections, and don't set a layout
  3. Start a dev server, see it builds fine
  4. Save the eleventy config file to trigger a change and rebuild

Expected behavior

Build should succeed on every run.

Reproduction URL

No response

Screenshots

Stack trace:

[11ty] Problem writing Eleventy templates:
[11ty] `templateRender` has not yet initialized on ./src/search.11ty.js
[11ty] 
[11ty] Original error stack trace: Error: `templateRender` has not yet initialized on ./src/search.11ty.js
[11ty]     at get templateRender [as templateRender] (./node_modules/@11ty/eleventy/src/TemplateContent.js:153:10)
[11ty]     at get engine [as engine] (./node_modules/@11ty/eleventy/src/TemplateContent.js:148:15)
[11ty]     at Template.isFileRelevantToThisTemplate (./node_modules/@11ty/eleventy/src/TemplateContent.js:679:30)
[11ty]     at TemplateWriter._addToTemplateMapIncrementalBuild (./node_modules/@11ty/eleventy/src/TemplateWriter.js:196:10)
[11ty]     at TemplateWriter._addToTemplateMap (./node_modules/@11ty/eleventy/src/TemplateWriter.js:334:22)
[11ty]     at TemplateWriter._createTemplateMap (./node_modules/@11ty/eleventy/src/TemplateWriter.js:349:14)
[11ty]     at TemplateWriter.generateTemplates (./node_modules/@11ty/eleventy/src/TemplateWriter.js:382:14)
[11ty]     at TemplateWriter.write (./node_modules/@11ty/eleventy/src/TemplateWriter.js:431:49)
[11ty]     at async Eleventy.executeBuild (./node_modules/@11ty/eleventy/src/Eleventy.js:1436:19)
[11ty]     at async #watch (./node_modules/@11ty/eleventy/src/Eleventy.js:973:52)

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions