caddy: stream xxx canceled by remote with error code 268

I often receive the following error in my caddy logs while doing speed tests with librespeed:

{
   "level":"error",
   "ts":1692452491.2814867,
   "logger":"http.handlers.reverse_proxy",
   "msg":"aborting with incomplete response",
   "upstream":"localhost:8085",
   "duration":0.005322624,
   "request":{
      "remote_ip":"192.168.178.20",
      "remote_port":"60436",
      "client_ip":"192.168.178.20",
      "proto":"HTTP/3.0",
      "method":"GET",
      "host":"speed.example.com",
      "uri":"/backend/garbage.php?r=0.6473048564721796&ckSize=100",
      "headers":{
         "Accept-Encoding":[
            "gzip, deflate, br"
         ],
         "Sec-Fetch-Mode":[
            "cors"
         ],
         "User-Agent":[
            "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0"
         ],
         "X-Forwarded-For":[
            "192.168.178.20"
         ],
         "Referer":[
            "https://speed.example.como/speedtest_worker.js?r=0.8378941592896734"
         ],
         "Sec-Fetch-Dest":[
            "empty"
         ],
         "Sec-Fetch-Site":[
            "same-origin"
         ],
         "Cache-Control":[
            "no-cache"
         ],
         "Alt-Used":[
            "speed.example.com"
         ],
         "Accept-Language":[
            "de,en-US;q=0.7,en;q=0.3"
         ],
         "Dnt":[
            "1"
         ],
         "Pragma":[
            "no-cache"
         ],
         "Accept":[
            "*/*"
         ],
         "X-Forwarded-Proto":[
            "https"
         ],
         "X-Forwarded-Host":[
            "speed.example.com"
         ]
      },
      "tls":{
         "resumed":true,
         "version":772,
         "cipher_suite":4865,
         "proto":"h3",
         "server_name":"speed.example.com"
      }
   },
   "error":"writing: stream 80 canceled by remote with error code 268"
}

The mixture of HTTP/3 and librespeed canceling the requests seems to trigger this (bogus?) error.

grafik

About this issue

  • Original URL
  • State: open
  • Created 10 months ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

@mholt v0.39 is available with the fix

I will update it shortly 😃 Thanks! (Been busy on a new Caddy website/docs.)

Great! Implementation is here: https://github.com/quic-go/quic-go/pull/4039. Planned for the v0.39 release.

Ah, that works for me then! I like the error code approach. (I guess that’s the point of an error code.)

The string representation of the error would then contain the name of the error (e.g. H3_REQUEST_CANCELLED for error 268).

Would there be a way to use types to know this kind of error? For example errors.Is(...)?

For errors.Is we’d have to introduce a new type for every error defined in the RFC: https://datatracker.ietf.org/doc/html/rfc9114#name-http-3-error-codes.

With the proposal from https://github.com/caddyserver/caddy/issues/5766#issuecomment-1685889137, you’d do the error assertion like this:

var http3Err *http3.Error
if errors.As(err, &http3Err) {
    if http3Err.ErrorCode == http3.ErrCodeRequestCanceled {
          // request cancelled
    }
}

Any preferences?