scotty-web / scotty

Haskell web framework inspired by Ruby's Sinatra, using WAI and Warp (Official Repository)
http://hackage.haskell.org/package/scotty
BSD 3-Clause "New" or "Revised" License
1.72k stars 134 forks source link

Errors no longer reported in stdout scotty-0.20.1 #404

Open chrissound opened 1 month ago

chrissound commented 1 month ago
{-# LANGUAGE OverloadedStrings #-}  
module Main where

import Web.Scotty

main :: IO ()
main = do
  scotty 3000 $ do
    get "/test" $ do
      error "test"

Previously in scotty-0.12.1 this would have printed something like:

CallStack (from HasCallStack):
  error, called at src/Main.hs:16:7 in main:Main

But now there is literally no output

ocramz commented 1 month ago

Hm, I don't think there's a way to disable error from crashing the app, are you sure you're hitting the right endpoint?

chrissound commented 1 month ago

Yup 99% sure. This unexpected behavior does not to happen on the latest release (scotty 0.22 from hackage), so it's fixed there but broken likely for some versions prior.

If you're familiar with nix I have a full minimal example here: https://github.com/chrissound/scotty-error-issue

It seems 0.20 and 0.21 is affected as well. One good thing is it's fixed now already, actually I'm not sure if this github issue should remain open in that case. At least it's documented.

ocramz commented 1 month ago

so, we did in fact overhaul exceptions handling in recent versions but I don't see how error would be affected.

chrissound commented 1 month ago

Are you perhaps able to replicate? I tried creating a failing test case for this, but didn't have much luck. I also tried creating a github action a moment ago but for some reason the whole body response isn't even appearing https://github.com/chrissound/scotty-error-issue/actions/runs/10497035641/job/29078973137 :/

chrissound commented 1 month ago

I think it was output buffering being an issue on my previous github action. None the less I'm able to replicate this finally on: https://github.com/chrissound/scotty-error-issue/actions/runs/10507995937/job/29110936575#step:4:808

I wonder if it's perhaps an issue related to output buffering in the first place though? In any case adding

hSetBuffering stdin NoBuffering
hSetBuffering stdout NoBuffering

Does not fix it locally or on github actions.