Properly handle errors originating from included files when compileDebug is enabled#3269
Properly handle errors originating from included files when compileDebug is enabled#3269ForbesLindesay merged 3 commits intopugjs:masterfrom
Conversation
pug (3.0.0 → 3.0.1)Bug Fixes
pug-runtime (3.0.0 → 3.0.1)Bug Fixes
Packages With No ChangesThe following packages have no user facing changes, so won't be released:
|
If compileDebug is enabled, a Buffer would be serialized and then pug-runtime would try to split() it assuming it would always be a string.
|
Thanks for this. The fix will need to be done where we create the Line 167 in 06baa52 I think the best bet would be to move that code into the Line 85 in 06baa52 lex so it would produce a smaller output via not having any non-pug includes.
P.S. the filename should be available as |
|
@ForbesLindesay Finally had time to revisit this. I also got tired of manually modifying the sources to apply this patch every time my template code has an error just so I can see what it was. :) I moved the Buffer check code to the |
When calling render/compile with
{ compileDebug: true }, and an error was thrown from (or due to) a local, thestrparameter inpug_rethrowwas atoJSON()'dBuffer, and the rethrow code tried tosplitit like a string.strwould be something like:which is what happens when you do something like
Buffer.from('foo').toJSON().I couldn't really figure out where or how it happens, but I just made the rethrow function gracefully handle those serialized
Bufferobjects properly.I wrote a test that failed (basically just calls an undefined function from an included file):

and then fixed it in this PR.