Timeout for pure values
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 38/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- haskell
- Ambito
- backend, networking
Direzione di ricerca
Start with the Haskell reproduction in the issue, then inspect processRequest and runServerHandler in Snap.Internal.Http.Server.Session. Trace how the ByteString response body is evaluated relative to the timeout deadline. Done means the provided handler reliably times out after five seconds without requiring writeBS $!.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Continuing the conversation from here: https://github.com/snapframework/snap-core/issues/283
tl;dr Handlers seem not to correctly time out if computing a pure value causes them to overrun their time deadline.
Repro:
{-# LANGUAGE OverloadedStrings #-}
import Snap.Core
import Snap.Http.Server
import qualified Data.List as L
main = quickHttpServe hmm
hmm :: Snap ()
hmm = do
setTimeout 5
writeBS $ if L.find (==1) (repeat 0) == Just 1 then "A" else "B"
If you curl 'localhost:8000', it won't time out in 5 seconds, or seemingly ever. If you change writeBS $ to writeBS $!, though, forcing the value to WHNF is enough to properly time out.
The problem, I hypothesize, is that the hmm function is immediately returning a thunk, and thus not timing out.
My (hand-wavy) proposal is to force to WHNF (or normal form) the ByteString response body, in order to correctly time out. This'll prevent malicious input (to vulnerable handlers) from creating "permanent" un-killed response threads.
Functions I might try and update are processRequest or runServerHandler in Snap.Internal.Http.Server.Session.
I can try to hack on this but it'd be good to know if it's the right way forward first.
- Lingua principale
- Haskell
- Stelle
- 197
- Fork
- 87
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di snapframework/snap-server
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
snapframework/snap-server#96 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
snapframework/snap-server#94 · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
snapframework/snap-server#92 · 2 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
snapframework/snap-server#85 · 8 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
snapframework/snap-server#77 · 2 commenti ·
Tutte le issue di snapframework/snap-server
Issue simili
-
typst-0.12 Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
commercialhaskell/stackage#8127 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
input-output-hk/haskell.nix#2573 ·
-
docs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
needs triage type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100