-
Notifications
You must be signed in to change notification settings - Fork 0
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
Mitigate TemplateContentPrematureUseError
case introduced in 4.1.1
#120
Comments
I was looking at this as well when you brought it up yesterday and did some looking- didn't see any immediate solution. I believe you are correct that the issue is coming from the plugin, as the current Vento rewrite is on the same version of Eleventy as my previous Nunjucks setup, and I wasn't seeing the issue there. Thanks again for looking into this! |
Related: 11ty/eleventy#2328 |
Also related: 11ty/eleventy#975 |
Update: Looks like the issue happened when this plugin moved to vento 1.12.14. I'll check the diff and figure out how to navigate around that since it seems like Eleventy really doesn't like other libraries handling its errors as indicated in that first issue I mentioned...although why this causes Eleventy to crash is beyond me... |
Ok, it gets weirder...never have I ever haha... @uncenter if you've got any ideas on where to go from here, I'm open to suggestions becuase there's definitely something going on that requires hacking around and I'd rather do it cleanly than patch over wierd issues and I definitely don't want to force Oscar to make Vento bend to Eleventy's conventions, particularly when he decided to write Lume instead... 😅 Apparently this commit that removed extending an error message is the problem. I have no idea why not appending something to the error message has anything to do with accessing the template content but just to make sure...
If you've got any ideas about where to go next, let me know! |
Strangely, usage of ---
eleventyImport:
collections: ["posts"]
--- |
Someone opened 11ty/eleventy#3630 as well which I believe is the same issue with the RSS plugin / collections. I'll keep an eye on it. |
Hmm, interesting. I see they posted a workaround as of 12 hours prior to me writing this comment. Can you test and confirm if that corrects the issue? If so then I think this is on Eleventy to fix because otherwise I can't see how this error gets thrown as I showed above. |
I don't think it fixes it for me. The error I'm getting when I update
I wonder why I'm not getting the - "eleventy-plugin-vento": "^4.0.1",
+ "eleventy-plugin-vento": "^4.1.1", |
The error reworking we identified in #96 (comment) and implemented in 11ty/eleventy#3572 won't be available until Eleventy 3.0.1 gets released. On 3.0.0 and lower, the details of the error stack are hidden from you. Try installing |
Ah, right, sorry I forgot I needed to update that as well 😓 |
No worries! It definitely has something to do with the removal of the error message in Vento, which makes no sense to me at all. #140 is pending because if I can fix this I'd add it to the release. Otherwise, I can merge and release ASAP which will update Vento to 1.12.15, which might eliminate it as being the problem. However, I still think there's some weird logic handling happening in Eleventy regarding error messages and something with Vento is tripping Eleventy up. |
Thanks again for helping my figure out this strange issue! Fwiw I pushed up a branch on my website repository if you need it for testing - I switched over from a custom fork of the RSS plugin to the official one there to try to narrow down possible edge cases (still no luck though, even when trying to rename the EDIT: Silly me, here is that PR: uncenter/uncenter.dev#260 |
Ended up just adding a patch for that one line you mentioned earlier for now. uncenter/uncenter.dev@6275dbf |
Cool. I'm going to keep this issue open while I continue to investigate. I have a feeling that modifying the error message somehow tricked Eleventy into proceeding with the build, but again I don't know for sure until I do more tests. Probably the best way to handle it would be to do some sort of error catching for At this point, I hate to bother @zachleat, but if anyone would know how errors work and why this issue is what it is, it would be him. Gut feeling is this somehow relates to 11ty/eleventy#2328, so when I get a moment to do more testing I'll update this issue accordingly. |
Fwiw I have two feed templates, one for JSON feed and the other for RSS/ATOM. The JSON feed always works and looks fine in the output directory, but the RSS one fails until I add that patch (and then builds and looks fine in the output directory). The JSON feed template is a JS template file and the RSS feed is in a Vento file. |
@uncenter GOT IT!! The PR above is on the right track: When Eleventy tries to access template content, if the template content hasn't been rendered yet, Eleventy catches the "premature use" error and queues the template for rendering, then tries again after the template has been rendered. It uses this function on the The PR I opened (11ty/eleventy#3572) to introduce checking the To be honest, I don't know why this sort of functionality is mixed in with error throwing because we end up with cases like this. To reiterate what the issue is:
So TLDR Eleventy blames Vento blames Eleventy waiting for a "premature use error" that was pre-caught. 😮💨 It seems like the best way to fix this is to patch Eleventy's error util that I linked above. I don't have time right now to open a PR but might in a day or two. At least now we know where the issue is coming from! |
Wow thanks for the write up, good catch! |
PR was submitted. Once that gets merged this issue can get closed and also a bunch of stuff that was blocked from releasing can go out. Cheers! |
While addressing #96 for @uncenter I noticed that builds of their site were throwing
TemplateContentPrematureUseError
. Becuase it wasn't relevant to that issue I closed it as fixed. Since I now suspect this plugin is indeed the cause of the issue, I'm going to investigate further.Some to-do's:
Relevant notes:
TemplateContentPrematureUseError
specifically is getting thrown.The text was updated successfully, but these errors were encountered: