Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wai-app-static without cryptonite #874

Merged

Conversation

amesgen
Copy link
Contributor

@amesgen amesgen commented Mar 18, 2022

Fixes a bug introduced in #871.

Without this, I get

hGetBufSome: illegal operation (handle is closed)

with defaultWebAppSettings.


  • Bumped the version number
  • Update the Changelog.md file with a link to your PR
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts)

@ysangkok
Copy link
Contributor

Thank you for the patch, sorry I didn't do this correctly. I reproduced the issue with the following patch to sample.hs:

diff --git a/wai-app-static/sample.hs b/wai-app-static/sample.hs
index b9cc2510..c8aa23d7 100644
--- a/wai-app-static/sample.hs
+++ b/wai-app-static/sample.hs
@@ -1,17 +1,21 @@
+{- cabal:
+    build-depends: wai-app-static
+                 , base
+                 , text
+                 , warp
+-}
 {-# LANGUAGE OverloadedStrings #-}
 
 import Data.String
 import Data.Text (pack)
 import Data.Maybe (mapMaybe)
 import WaiAppStatic.Types (ssIndices, toPiece)
-import Network.Wai.Application.Static (staticApp,defaultFileServerSettings)
-import Network.Wai.Handler.Warp (runSettings, settingsPort, defaultSettings)
+import Network.Wai.Application.Static (staticApp,defaultWebAppSettings)
+import Network.Wai.Handler.Warp (runSettings, setPort, defaultSettings)
   
 main :: IO ()
-main = runSettings defaultSettings
-    {
-        settingsPort = 3000
-    } $ staticApp (defaultFileServerSettings $ fromString ".")
+main = runSettings (setPort 3000 defaultSettings)
+    $ staticApp (defaultWebAppSettings $ fromString ".")
     {
       ssIndices = mapMaybe (toPiece . pack) ["index.html"]
     }

This PR does indeed fix the problem.

Copy link
Member

@snoyberg snoyberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@snoyberg snoyberg merged commit 2bbd1f7 into yesodweb:master Mar 20, 2022
@amesgen amesgen deleted the fix-wai-app-static-without-cryptonite branch March 20, 2022 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants