From 19ac6a0c8f1aedc103480a09fddfdf6b37c03176 Mon Sep 17 00:00:00 2001 From: Sebastian Estrella <2049686+sestrella@users.noreply.github.com> Date: Fri, 16 May 2025 11:53:23 -0500 Subject: [PATCH 1/9] fix: Fix race condition on WaiSpec (Copilot) --- rollbar-wai/src/Rollbar/Wai.hs | 9 +++++---- rollbar-wai/test/Rollbar/WaiSpec.hs | 5 +---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/rollbar-wai/src/Rollbar/Wai.hs b/rollbar-wai/src/Rollbar/Wai.hs index 3cdc224..963f212 100644 --- a/rollbar-wai/src/Rollbar/Wai.hs +++ b/rollbar-wai/src/Rollbar/Wai.hs @@ -50,7 +50,7 @@ rollbarOnException -> Maybe W.Request -> SomeException -> m () -rollbarOnException = rollbarOnExceptionWith (void . createItem) +rollbarOnException settings = rollbarOnExceptionWith (void . forkIO) (void . createItem) settings -- | Similar to 'rollbarOnExceptionWith', but it allows customize the function -- used to send the 'Item' to Rollbar. @@ -58,13 +58,14 @@ rollbarOnException = rollbarOnExceptionWith (void . createItem) -- @since 0.1.0 rollbarOnExceptionWith :: MonadIO m - => (Item -> Rollbar ()) + => (IO () -> IO ()) -- ^ fork function (returns unit) + -> (Item -> Rollbar ()) -> Settings -> Maybe W.Request -> SomeException -> m () -rollbarOnExceptionWith f settings waiRequest ex = - void $ liftIO $ forkIO $ runRollbar settings $ do +rollbarOnExceptionWith fork f settings waiRequest ex = + void $ liftIO $ fork $ runRollbar settings $ do item <- mkItem $ PayloadTrace $ Trace [] $ mkException ex request <- mapM mkRequest waiRequest f item diff --git a/rollbar-wai/test/Rollbar/WaiSpec.hs b/rollbar-wai/test/Rollbar/WaiSpec.hs index 8dd8edc..df822de 100644 --- a/rollbar-wai/test/Rollbar/WaiSpec.hs +++ b/rollbar-wai/test/Rollbar/WaiSpec.hs @@ -10,7 +10,6 @@ import qualified Data.Text as T import qualified Network.Wai as W import qualified Network.Wai.Handler.Warp as W -import Control.Concurrent (threadDelay) import Control.Monad (join) import Control.Monad.IO.Class import Data.Aeson @@ -33,7 +32,6 @@ spec = before getSettingsAndItemRef $ (req GET url NoReqBody bsResponse $ port warpPort) responseStatusCode response `shouldBe` 200 responseBody response `shouldBe` "OK" - threadDelay 500 readIORef itemRef `shouldReturn` Nothing context "when the response status code is not 200" $ @@ -44,7 +42,6 @@ spec = before getSettingsAndItemRef $ (defaultHttpConfig { httpConfigCheckResponse = \_ _ _ -> Nothing }) (req GET url NoReqBody bsResponse $ port warpPort) response `shouldBe` "Something went wrong" - threadDelay 500 let portAsText = T.pack $ show warpPort join . fmap itemRequest <$> readIORef itemRef `shouldReturn` Just ( Request @@ -75,7 +72,7 @@ withApp -> IO a withApp f (settings, itemRef) = do let waiSettings = W.setOnException - (rollbarOnExceptionWith (createItemFake itemRef) settings) + (rollbarOnExceptionWith id (createItemFake itemRef) settings) W.defaultSettings W.withApplicationSettings waiSettings (return app) $ f itemRef From fc9acf856e9b37c1d69f104734bf92bc03970943 Mon Sep 17 00:00:00 2001 From: Sebastian Estrella <2049686+sestrella@users.noreply.github.com> Date: Fri, 16 May 2025 12:02:22 -0500 Subject: [PATCH 2/9] Update ChangeLog via Copilot --- rollbar-wai/ChangeLog.md | 7 ++++++- rollbar-wai/rollbar-wai.cabal | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/rollbar-wai/ChangeLog.md b/rollbar-wai/ChangeLog.md index 9064ccc..c233335 100644 --- a/rollbar-wai/ChangeLog.md +++ b/rollbar-wai/ChangeLog.md @@ -8,4 +8,9 @@ All notable changes to this project will be documented in this file. - Added support for GHC 9.4 - Changed `text` dependency upper bound: we now support `text-2.0.X.X`. -## Unreleased changes +## [1.2.0] - 2025-05-16 + +### Changed +- `rollbarOnExceptionWith` now takes a fork function of type `IO () -> IO ()`. +- All tests are now synchronous and no longer use `threadDelay`. +- Updated `rollbarOnException` and all usages to match the new signature. diff --git a/rollbar-wai/rollbar-wai.cabal b/rollbar-wai/rollbar-wai.cabal index 3e7252a..22ee79d 100644 --- a/rollbar-wai/rollbar-wai.cabal +++ b/rollbar-wai/rollbar-wai.cabal @@ -5,7 +5,7 @@ cabal-version: 1.12 -- see: https://github.com/sol/hpack name: rollbar-wai -version: 1.1.1 +version: 1.2.0 synopsis: Provides error reporting capabilities to WAI based applications through Rollbar API. description: Please see the README on GitHub at From 16eb6e9ac7209b28b6610ae40902cdf048429d4e Mon Sep 17 00:00:00 2001 From: Sebastian Estrella <2049686+sestrella@users.noreply.github.com> Date: Fri, 16 May 2025 12:03:35 -0500 Subject: [PATCH 3/9] Remove settings param --- rollbar-wai/src/Rollbar/Wai.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rollbar-wai/src/Rollbar/Wai.hs b/rollbar-wai/src/Rollbar/Wai.hs index 963f212..437c2e3 100644 --- a/rollbar-wai/src/Rollbar/Wai.hs +++ b/rollbar-wai/src/Rollbar/Wai.hs @@ -50,7 +50,7 @@ rollbarOnException -> Maybe W.Request -> SomeException -> m () -rollbarOnException settings = rollbarOnExceptionWith (void . forkIO) (void . createItem) settings +rollbarOnException = rollbarOnExceptionWith (void . forkIO) (void . createItem) -- | Similar to 'rollbarOnExceptionWith', but it allows customize the function -- used to send the 'Item' to Rollbar. From c6a76eafa9321366b144dc41bbadc6eb90b24262 Mon Sep 17 00:00:00 2001 From: Sebastian Estrella <2049686+sestrella@users.noreply.github.com> Date: Fri, 16 May 2025 12:07:04 -0500 Subject: [PATCH 4/9] Change label on ChangeLog --- rollbar-wai/ChangeLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rollbar-wai/ChangeLog.md b/rollbar-wai/ChangeLog.md index c233335..0a00ce0 100644 --- a/rollbar-wai/ChangeLog.md +++ b/rollbar-wai/ChangeLog.md @@ -8,7 +8,7 @@ All notable changes to this project will be documented in this file. - Added support for GHC 9.4 - Changed `text` dependency upper bound: we now support `text-2.0.X.X`. -## [1.2.0] - 2025-05-16 +## Unreleased changes ### Changed - `rollbarOnExceptionWith` now takes a fork function of type `IO () -> IO ()`. From 3fde693dd338ccd98ccd3435528fdb2b446c10ed Mon Sep 17 00:00:00 2001 From: Sebastian Estrella <2049686+sestrella@users.noreply.github.com> Date: Fri, 16 May 2025 15:25:43 -0500 Subject: [PATCH 5/9] Update GHC compiler version --- flake.lock | 8 ++++---- flake.nix | 9 +++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index be181da..be94ed7 100644 --- a/flake.lock +++ b/flake.lock @@ -20,16 +20,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1701263465, - "narHash": "sha256-lNXUIlkfyDyp9Ox21hr+wsEf/IBklLvb6bYcyeXbdRc=", + "lastModified": 1747209494, + "narHash": "sha256-fLise+ys+bpyjuUUkbwqo5W/UyIELvRz9lPBPoB0fbM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "50aa30a13c4ab5e7ba282da460a3e3d44e9d0eb3", + "rev": "5d736263df906c5da72ab0f372427814de2f52f8", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-23.11", + "ref": "nixos-24.11", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index c3dd9a5..8bc3730 100644 --- a/flake.nix +++ b/flake.nix @@ -1,10 +1,15 @@ { inputs = { flake-utils.url = "github:numtide/flake-utils"; - nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; }; - outputs = { self, flake-utils, nixpkgs }: + outputs = + { + self, + flake-utils, + nixpkgs, + }: flake-utils.lib.simpleFlake { inherit self nixpkgs; name = "rollbar-haskell"; From 64a38c66850ce5db36c1bbb88c0010f42aa278d9 Mon Sep 17 00:00:00 2001 From: Sebastian Estrella <2049686+sestrella@users.noreply.github.com> Date: Fri, 16 May 2025 15:25:56 -0500 Subject: [PATCH 6/9] Fix compilation errors --- rollbar-yesod/src/Rollbar/Yesod.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rollbar-yesod/src/Rollbar/Yesod.hs b/rollbar-yesod/src/Rollbar/Yesod.hs index 24e67ef..9b150ac 100644 --- a/rollbar-yesod/src/Rollbar/Yesod.hs +++ b/rollbar-yesod/src/Rollbar/Yesod.hs @@ -17,6 +17,7 @@ module Rollbar.Yesod import qualified Network.Wai as W +import Control.Concurrent (forkIO) import Control.Exception (Exception(..), SomeException) import Control.Monad (unless, void) import Rollbar.Client @@ -40,7 +41,7 @@ rollbarYesodMiddleware => m a -> m a rollbarYesodMiddleware = rollbarYesodMiddlewareWith $ \settings request ex -> - rollbarOnExceptionWith handler settings (Just request) ex + rollbarOnExceptionWith (void . forkIO) handler settings (Just request) ex where handler item = void $ createItem item { itemFramework = Just "yesod" } From a7f9da4fcec6fa1442ee3658d3363eec7c08b6b0 Mon Sep 17 00:00:00 2001 From: Sebastian Estrella <2049686+sestrella@users.noreply.github.com> Date: Fri, 16 May 2025 15:28:20 -0500 Subject: [PATCH 7/9] Bump version constraint for rollbar-yesod --- rollbar-wai/package.yaml | 2 +- rollbar-yesod/package.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rollbar-wai/package.yaml b/rollbar-wai/package.yaml index 88d8dec..599a28e 100644 --- a/rollbar-wai/package.yaml +++ b/rollbar-wai/package.yaml @@ -1,5 +1,5 @@ name: rollbar-wai -version: 1.1.1 +version: 1.2.0 github: "stackbuilders/rollbar-haskell" license: MIT author: "Stack Builders Inc." diff --git a/rollbar-yesod/package.yaml b/rollbar-yesod/package.yaml index ff17c88..0ddb22d 100644 --- a/rollbar-yesod/package.yaml +++ b/rollbar-yesod/package.yaml @@ -41,7 +41,7 @@ library: source-dirs: src dependencies: - rollbar-client >= 1.0 && < 2 - - rollbar-wai >= 1.0 && < 2 + - rollbar-wai >= 1.2 && < 2 - unliftio >= 0.2 && < 1 - wai >= 3.2 && < 4 - yesod-core >= 1.6 && < 2 From f7e0bf119135fe50aae43366e5025fd4e111cf4b Mon Sep 17 00:00:00 2001 From: Sebastian Estrella <2049686+sestrella@users.noreply.github.com> Date: Fri, 16 May 2025 15:29:05 -0500 Subject: [PATCH 8/9] Bump version for rollbar-yesod --- rollbar-yesod/package.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rollbar-yesod/package.yaml b/rollbar-yesod/package.yaml index 0ddb22d..908cb73 100644 --- a/rollbar-yesod/package.yaml +++ b/rollbar-yesod/package.yaml @@ -1,5 +1,5 @@ name: rollbar-yesod -version: 1.1.1 +version: 1.1.2 github: "stackbuilders/rollbar-haskell" license: MIT author: "Stack Builders Inc." From d8b29e84485e3f9b6b5ba6df500cdf7d40af1253 Mon Sep 17 00:00:00 2001 From: Sebastian Estrella <2049686+sestrella@users.noreply.github.com> Date: Fri, 16 May 2025 15:29:26 -0500 Subject: [PATCH 9/9] Generate rollbar-yesod.cabal from package.yml --- rollbar-yesod/rollbar-yesod.cabal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rollbar-yesod/rollbar-yesod.cabal b/rollbar-yesod/rollbar-yesod.cabal index 8649350..275caa0 100644 --- a/rollbar-yesod/rollbar-yesod.cabal +++ b/rollbar-yesod/rollbar-yesod.cabal @@ -5,7 +5,7 @@ cabal-version: 1.12 -- see: https://github.com/sol/hpack name: rollbar-yesod -version: 1.1.1 +version: 1.1.2 synopsis: Provides error reporting capabilities to Yesod applications through Rollbar API. description: Please see the README on GitHub at @@ -45,7 +45,7 @@ library build-depends: base >=4.18 && <5 , rollbar-client >=1.0 && <2 - , rollbar-wai >=1.0 && <2 + , rollbar-wai >=1.2 && <2 , unliftio >=0.2 && <1 , wai >=3.2 && <4 , yesod-core >=1.6 && <2