Handle exceptions with cached templates #156
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We ran into an issue where errors thrown by cached templates kill the application in such a way that it cannot recover. The process itself is corrupted in such a way that spawning new workers (we’re using lthe
cluster
module) resulted in those new workers dying immediately. @shawnsi found that this seems to be the case for Node.js in Linux (CentOS), yet not in macOS.After a lot of debugging, we identified
hbs
as the root cause, as it does not handle errors stemming from cached templates the way it handles them for newly-loaded templates. We haven’t delved too deeply into why this is a problem in one platform and not others.This PR adds error handling for cached templates similar to the way errors are handled for non-cached templates. We’ve found that errors thrown at render time from a bad template or a template invoked with bad data are handle consistently with this fix, and that the application remains healthy and stable.