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

Disable WAI timeouts altogether #265

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion grapesy/grapesy.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ library
, recv >= 0.1 && < 0.2
, stm >= 2.5 && < 2.6
, text >= 1.2 && < 2.2
, time-manager >= 0.2.1 && < 0.3
, time-manager >= 0.2.2 && < 0.3
, tls >= 1.7 && < 2.2
, unbounded-delays >= 0.1.1 && < 0.2
, unordered-containers >= 0.2 && < 0.3
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
28 changes: 3 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,8 @@ 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 as of @time-manager-0.2.2@.
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