scotty icon indicating copy to clipboard operation
scotty copied to clipboard

Errors no longer reported in stdout scotty-0.20.1

Open chrissound opened this issue 1 year ago • 5 comments

{-# 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

chrissound avatar Aug 18 '24 19:08 chrissound

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?

ocramz avatar Aug 18 '24 19:08 ocramz

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.

chrissound avatar Aug 18 '24 20:08 chrissound

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

ocramz avatar Aug 21 '24 20:08 ocramz

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 avatar Aug 21 '24 20:08 chrissound

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.

chrissound avatar Aug 22 '24 12:08 chrissound