digitallyinduced / ihp

🔥 The fastest way to build type safe web apps. IHP is a new batteries-included web framework optimized for longterm productivity and programmer happiness

Home Page:https://ihp.digitallyinduced.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"502 Bad Gateway" when `respondHtml` endpoint misses parameter

kodeFant opened this issue · comments

When using respondHtml, and a required param is not provided, something nasty happens to the nginx proxy on a production NixOS server.

Example:

action SomeAction =
    let someParam = param @Text "someParam"
    respondHtml [hsx|{someParam}|]

And then call http://siteUrl/SomeAction directly without the required parameter.

I get an nginx 502 Bad Gateway response which also takes the whole proxy down until systemd automatically restarts it.

It leads to a couple of seconds of downtime, making it possible for any user to bring the server down.

I would expect the error to be properly catched with an IHP error, as it seems to be with the render function (I think?).

The workaround would of course be to use paramOrNothing, although a bit inconvenient to remember.

Some additional info provided on this issue: #1837