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

Error message provides incorrect/misleading information #3183

Open
boehs opened this issue Feb 1, 2024 · 0 comments
Open

Error message provides incorrect/misleading information #3183

boehs opened this issue Feb 1, 2024 · 0 comments
Labels

Comments

@boehs
Copy link

boehs commented Feb 1, 2024

v3.0.0-alpha.4

I have a writeup here: https://boehs.org/node/investigating-a-11ty-race-condition

A portion of the post has been copied below:


This error is incorrect:

[11ty] Problem writing Eleventy templates: (more in DEBUG output) [11ty] 1. Having trouble writing to "out/og/node/lorum.png" from "./src/og.11ty.js" (via EleventyTemplateError)
[11ty] 2. Transform `html` encountered an error when transforming ./src/og.11ty.js. (via EleventyTransformError)

Modifying 11ty source code for the second error to report the output shows the real output file:

} catch (e) {
	throw new EleventyTransformError(
		`Transform \`${name}\` encountered an error when transforming ${inputPath} into "${outputPath}"`,
		e,
	);
}
1. Having trouble writing to "out/og/node/lorum.png" from "./src/og.11ty.js" (via EleventyTemplateError)
2. Transform 'htmlmin' encountered an error when transforming ./src/og.11ty.js into "out/og/index.html". (via EleventyTransformError)

So why is it incorrect in the first error?

Because, the way 11ty works is it internally makes a queue of all the templates that need to be transformed. Because most templates are the actual content, this usually works, but pagination is one template making many output files. There was a hack employeed, where the first file that will be outputted is set as the output file for use in error messages to avoid breaking other code:

for (let page of map._pages) {
	// Copy outputPath to map entry
	if (!map.outputPath) {
		map.outputPath = page.outputPath;
	}
}

But, this means that I’m being told false information! And, without modifying 11ty source, there’s no good way to get correct information! No wonder I was confused!


Zach, I wrote it another way in your discord DMs

Discussion in the 11ty discord here: https://discord.com/channels/741017160297611315/1201882327509368892

@zachleat zachleat added the bug label Apr 10, 2024
@zachleat zachleat added this to the Eleventy 3.0.0 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants