Closed mweberxyz closed 5 months ago
The first send
occurs in the catch handler in readCallbackParser
, which then returns undefined. Then in 3 cases, readCallbackEnd
is called with the compile
argument set to undefined, which catches an error (TypeError: compile is not a function), and that.send
is called with the second error.
The double-call to send
occurs whether the onError
is defined or not, so the crash itself is a symptom of the existence of the handler.
This issue is solved by https://github.com/fastify/point-of-view/pull/405
Great!
Can you please add a unit test to #405 and put closes #404
there
@gurgunday Added the test, but it didn't link this issue to the PR or vice versa. I assume because I am not a collaborator/member of this repo? 🤷♂️
Prerequisites
Fastify version
4.26.0
Plugin version
8.2.0
Node.js version
20.x
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
13.6.4
Description
When fastify has an
onError
hook defined, attempts to render an invalid template result in a server crash due to multiple calls tosend
.I am using the
ejs
engine and have only confirmed the bug with that engine.Steps to Reproduce
Upon loading in a browser:![CleanShot 2024-02-09 at 10 47 23](https://github.com/fastify/point-of-view/assets/1062734/cb631bc1-f576-49e1-ae6a-02034ac08664)
After commenting out the![CleanShot 2024-02-09 at 10 48 13](https://github.com/fastify/point-of-view/assets/1062734/34fc88ed-6fd6-4e7e-a4af-df4ca634b8dc)
onError
hook:Expected Behavior
Regardless of whether
onError
has been defined, failure to compile template should return an error to the client, rather than crashing the server.