well-typed / grapesy

Native Haskell gRPC client and server based on `http2`
Other
32 stars 4 forks source link

Deal with errors during compression #57

Open edsko opened 5 months ago

edsko commented 5 months ago

Compression is currently defined as

data Compression = Compression {
      compressionId :: CompressionId
    , compress :: Lazy.ByteString -> Lazy.ByteString
    , decompress :: Lazy.ByteString -> Lazy.ByteString
    }

The type of decompress should instead be

data Compression = Compression {
      compressionId :: CompressionId
    , compress :: Lazy.ByteString -> Lazy.ByteString
    , decompress :: Lazy.ByteString -> Either DecompresionFailure Lazy.ByteString
    }

And these decompression failures then need to propagate everywhere, and the specific instances of Compression (such as gzip) need to be modified.

edsko commented 3 months ago

Lowering the priority of this issue to low, since the probability that a peer sends us messages that have compression errors in them is very low.

If we implement this, we should think about whether the difficulty of streaming decompression whilst checking for errors is relevant or not (@FinleyMcIlwaine has some discussion of this issue at https://hackage.haskell.org/package/snappy-c-0.1.0/docs/Codec-Compression-SnappyC-Framed.html#v:decompressWithParams-39-).