Skip to content

Commit

Permalink
Disable WAI timeouts altogether
Browse files Browse the repository at this point in the history
Depends on yesodweb/wai#1017
Closes #123
  • Loading branch information
edsko committed Dec 17, 2024
1 parent 4a433df commit 987fcfd
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 27 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ jobs:
echo "package trailers-only-tutorial" >> cabal.project
echo " ghc-options: -Werror=missing-methods" >> cabal.project
cat >> cabal.project <<EOF
source-repository-package
type: git
location: https://github.com/kazu-yamamoto/wai.git
tag: 721782ad6e60f3ae4ff609b33c90e56921a4bddb
subdir: time-manager
source-repository-package
type: git
location: https://github.com/google/proto-lens
Expand Down
6 changes: 6 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ package grapesy
benchmarks: True
flags: +build-demo +build-stress-test

source-repository-package
type: git
location: https://github.com/kazu-yamamoto/wai.git
tag: 721782ad6e60f3ae4ff609b33c90e56921a4bddb
subdir: time-manager

-- proto-lens support for ghc 9.10
-- https://github.com/google/proto-lens/pull/494
source-repository-package
Expand Down
6 changes: 6 additions & 0 deletions cabal.project.ci
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ package conduit-tutorial
package trailers-only-tutorial
ghc-options: -Werror

source-repository-package
type: git
location: https://github.com/kazu-yamamoto/wai.git
tag: 721782ad6e60f3ae4ff609b33c90e56921a4bddb
subdir: time-manager

-- proto-lens support for ghc 9.10
-- https://github.com/google/proto-lens/pull/494
source-repository-package
Expand Down
2 changes: 0 additions & 2 deletions grapesy/src/Network/GRPC/Common/Compression.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{-# LANGUAGE CPP #-}

-- | Public 'Compression' API
--
-- Intended for qualified import.
Expand Down
29 changes: 4 additions & 25 deletions grapesy/src/Network/GRPC/Util/HTTP2.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{-# LANGUAGE CPP #-}

#include "MachDeps.h"

module Network.GRPC.Util.HTTP2 (
-- * General auxiliary
fromHeaderTable
Expand Down Expand Up @@ -219,26 +215,9 @@ mkTlsSettings http2Settings keyLogger =
withTimeManager :: (Time.Manager -> IO a) -> IO a
withTimeManager = TimeManager.withManager (disableTimeout * 1_000_000)

-- | Work around the fact that we cannot disable timeouts in http2/http2-tls
-- | Disable timeouts in http2/http2-tls
--
-- TODO: <https://github.com/well-typed/grapesy/issues/123>
-- We need a proper solution for this.
-- A value of 0 (or lower) disables timeouts altogether as of
-- <https://github.com/yesodweb/wai/pull/1017>.
disableTimeout :: Int
disableTimeout =
#if (WORD_SIZE_IN_BITS == 64)
-- Set a really high timeout to effectively disable timeouts (100 years)
--
-- NOTE: We cannot use 'maxBound' here, because this value is multiplied
-- by @1_000_000@ in 'Network.Run.TCP.Timeout.runTCPServerWithSocket'
-- (in @network-run@).
100 * 365 * 24 * 60 * 60
#else
#warning "Timeout for RPC messages is set to 30 minutes on 32-bit systems."
#warning "See https://github.com/kazu-yamamoto/http2/issues/112"
-- Unfortunately, the same trick does not work on 32-bit systems, where we
-- simply don't have enough range. The maximum timeout we can support here
-- is roughly 35 mins. We set it to 30 minutes exactly, to at least provide
-- a clue if the timeout does hit (1_800_000_000 < 2_147_483_647).
30 * 60
#endif

disableTimeout = 0

0 comments on commit 987fcfd

Please sign in to comment.