Skip to content

Refuse requests assigned to closed HTTP/2 connections - #246

Merged
samuel-williams-shopify merged 1 commit into
mainfrom
refuse-closed-http2-connection
Aug 31, 2026
Merged

Refuse requests assigned to closed HTTP/2 connections#246
samuel-williams-shopify merged 1 commit into
mainfrom
refuse-closed-http2-connection

Conversation

@samuel-williams-shopify

@samuel-williams-shopify samuel-williams-shopify commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

An HTTP/2 connection can close after the pool acquires it but before Client#call begins writing the request. At the existing closed? check, no response stream has been created and no request bytes have been written, so the request is known not to have been processed.

Raise Protocol::HTTP::RefusedError in this case so Async::HTTP::Client can safely retry the request, including non-idempotent requests with rewindable bodies.

HTTP/1 already has equivalent behavior in Protocol::HTTP1::Connection#write_request, which converts failures before a complete request is emitted into Protocol::HTTP::RefusedError.

Tests

  • Added coverage confirming that calling an already-closed HTTP/2 connection raises Protocol::HTTP::RefusedError for a POST request.
  • bundle exec bake test: 256 passed, 3 skipped.

Types of Changes

Bug fix

Contribution

  • I added tests for my changes.
  • I tested my changes locally.
  • I agree to the Developer Certificate of Origin 1.1.

Assisted-By: devx/618580b0-d55f-4c2e-95b6-87e648f60543
@samuel-williams-shopify
samuel-williams-shopify force-pushed the refuse-closed-http2-connection branch from a798026 to a2d8738 Compare August 31, 2026 03:32
@samuel-williams-shopify
samuel-williams-shopify merged commit e57967c into main Aug 31, 2026
35 of 46 checks passed
@samuel-williams-shopify
samuel-williams-shopify deleted the refuse-closed-http2-connection branch August 31, 2026 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant