Skip to content

HttpContext.Abort results in different error code for UseKestrel vs UseHttpSys #12256

Open

Description

@stephentoub

When the server aborts an HTTP/2 request, a RST_STREAM frame is sent. If UseKestrel is used, this frame contains an INTERNAL_ERROR error code. If UseHttpSys is used, this frame contains a CANCEL error code. CANCEL seems more correct to me, but regardless, seems we should be consistent.

cc: @halter73

Activity

  1. analogrelay commented on Jul 16, 2019

    @analogrelay
    Contributor

    CANCEL seems more correct to me, but regardless, seems we should be consistent.

    Consistency between HttpSysServer and Kestrel is not necessarily a requirement for us, servers differ in behavior all the time. Having said that, it sounds like CANCEL is more correct. Technically a client could be relying on the old behavior and would be broken by using CANCEL, but we think that's a pretty rare case.

    Let's change to cancel in 3.0. We can quirk it in a patch if necessary.

  2. added this to the 3.0.0-preview8 milestone on Jul 16, 2019
  3. Tratcher commented on Jul 17, 2019

    @Tratcher
    Member

    Kestrel has several abort-ish code paths and does not currently distinguish the error code for them.

    • HttpContext.Abort
    • App throwing an exception
    • Others?
  4. halter73 commented on Jul 17, 2019

    @halter73
    Member

    Sure, but it cannot be too difficult to distinguish user-initiated aborts. We were thinking about having an HTTP/2 specific abort API that let you specify the error code anyway for gRPC.

  5. halter73 commented on Jul 17, 2019

    @halter73
    Member

    I think I see what you mean though. It would be interesting to see if Http.Sys uses the CANCEL error code for the other cases too, like the app throwing an exception. In that case, I hope even Http.Sys uses the INTERNAL_ERROR error code.

  6. Tratcher commented on Jul 17, 2019

    @Tratcher
    Member

    Native Http.Sys doesn't expose any granular API there, I expect the error code is always cancel.

    Kestrel already has the Reset API that lets you specify the error code.

  7. stephentoub commented on Jul 17, 2019

    @stephentoub
    MemberAuthor

    It would be interesting to see if Http.Sys uses the CANCEL error code for the other cases too, like the app throwing an exception

    Http.Sys uses CANCEL for both HttpContext.Abort and an exception getting thrown.

  8. Tratcher commented on Jul 17, 2019

    @Tratcher
    Member

    Yeah, both call HttpCancelHttpRequest. https://msdn.microsoft.com/en-us/windows/desktop/aa814335

  9. analogrelay commented on Jul 17, 2019

    @analogrelay
    Contributor

    What seems most appropriate here is to use CANCEL for HttpContext.Abort and INTERNAL_ERROR for app exceptions. Consistency doesn't feel like a significant motivator here to me, and if anything indicates we should be pushing for more control over this in Http.Sys (which I believe we are already working on since gRPC uses the RST_STREAM error code as part of the protocol)

  10. analogrelay commented on Jul 26, 2019

    @analogrelay
    Contributor

    The 3.0 door has closed. We still believe this would be a valuable change though, so Backlogging.

  11. added
    affected-very-few
    bug
    severity-nice-to-have
    on Nov 12, 2020
  12. removed their assignment
    on Jul 14, 2021
  13. added
    area-networking
    and removed on Aug 24, 2023
  14. added theissue type on May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-very-fewarea-networkingbugseverity-nice-to-have

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions