Repository navigation
http: proxying 102s. - #19023
Merged
Merged
http: proxying 102s.#19023
Conversation
Signed-off-by: Alyssa Wilk <[email protected]>
Signed-off-by: Alyssa Wilk <[email protected]>
Signed-off-by: Alyssa Wilk <[email protected]>
Signed-off-by: Alyssa Wilk <[email protected]>
Contributor
Author
|
cc @RyanTheOptimist @DavidSchinazi now with 103s :-) |
RyanTheOptimist
previously approved these changes
Nov 16, 2021
RyanTheOptimist
left a comment
Contributor
There was a problem hiding this comment.
Woo hoo! Looks awesome. One small question.
| testEnvoyProxying1xx(false, false, true); | ||
| } | ||
|
|
||
| TEST_P(ProtocolIntegrationTest, EnvoyProxying102) { |
Contributor
There was a problem hiding this comment.
Should we also have a 103 test here?
DavidSchinazi
previously approved these changes
Nov 16, 2021
| * bandwidth_limit: added :ref:`bandwidth limit stats <config_http_filters_bandwidth_limit>` *request_enforced* and *response_enforced*. | ||
| * config: the log message for "gRPC config stream closed" now uses the most recent error message, and reports seconds instead of milliseconds for how long the most recent status has been received. | ||
| * dns: now respecting the returned DNS TTL for resolved hosts, rather than always relying on the hard-coded :ref:`dns_refresh_rate. <envoy_v3_api_field_config.cluster.v3.Cluster.dns_refresh_rate>` This behavior can be temporarily reverted by setting the runtime guard ``envoy.reloadable_features.use_dns_ttl`` to false. | ||
| * http: envoy will now proxy 102 and 103 headers from upstream, though as with 100s only the first 1xx response headers will be sent. This behavioral change by can temporarily revertd by setting runtime guard ``envoy.reloadable_features.proxy_102_103`` to false. |
Contributor
There was a problem hiding this comment.
Suggested change
| * http: envoy will now proxy 102 and 103 headers from upstream, though as with 100s only the first 1xx response headers will be sent. This behavioral change by can temporarily revertd by setting runtime guard ``envoy.reloadable_features.proxy_102_103`` to false. | |
| * http: envoy will now proxy 102 and 103 headers from upstream, though as with 100s only the first 1xx response headers will be sent. This behavioral change by can temporarily reverted by setting runtime guard ``envoy.reloadable_features.proxy_102_103`` to false. |
Signed-off-by: Alyssa Wilk <[email protected]>
alyssawilk
dismissed stale reviews from DavidSchinazi and RyanTheOptimist
via
November 17, 2021 14:22
c9370ad
Signed-off-by: Alyssa Wilk <[email protected]>
This was referenced Jun 12, 2024
RyanTheOptimist
pushed a commit
that referenced
this pull request
Jul 8, 2024
Proxying 104s from upstream. `104 Upload Resumption Supported` is introduced in [`draft-ietf-httpbis-resumable-upload`](https://datatracker.ietf.org/doc/draft-ietf-httpbis-resumable-upload/) spec. Continuation of the discussion in #19044 Modeled after: #19023 Risk Level: Low (minor refactor) Testing: new integration test Docs Changes: N/A Release Notes: > http: envoy will now proxy 104 headers from upstream, though as with 100s only the first 1xx response headers will be sent. This behavior can be temporarily reverted by setting runtime guard `envoy.reloadable_features.proxy_104` to false. 104 headers are designated by [ietf's draft-ietf-httpbis-resumable-upload rfc](https://datatracker.ietf.org/doc/draft-ietf-httpbis-resumable-upload/). Runtime guard: > `envoy.reloadable_features.proxy_104` --------- Signed-off-by: Neal Soni <[email protected]>
2 of 4 tasks
alco
pushed a commit
to neondatabase/electric
that referenced
this pull request
Apr 13, 2026
…meouts (#4106) ## Summary - Sends periodic HTTP `102 Processing` informational responses during long-poll holds to prevent network middleboxes (Cloudflare edge nodes on long paths to origin) from dropping idle connections (522 errors) - Zero client changes required — fully backwards compatible with existing TypeScript and Elixir clients - All 51 existing API tests pass with no modifications ## Problem Long-poll requests to `/v1/shape?live=true` hold connections idle for up to 20 seconds inside `hold_until_change`. During this time, no bytes flow on the wire. Middleboxes on long network paths (e.g., Cloudflare colos BAH, HKG hitting ALB in us-east-1) can drop these connections, causing sporadic 522 errors. ## Approach Uses `Plug.Conn.inform(conn, 102)` to send HTTP 1xx informational responses every 5–15 seconds during the hold. These responses: 1. **Send bytes on the wire** — keeps middlebox connections alive 2. **Don't commit the final response** — headers and status code are sent only after the hold resolves, with correct values 3. **Are invisible to HTTP clients** — `fetch()`, Req, and all standard HTTP clients transparently ignore 1xx responses per RFC 9110 §15.2 4. **Preserve CDN request collapsing** — since 1xx responses are not final responses, the CDN's coalescing window remains open for the full hold duration (see CDN section below) ### Implementation details - A `:timer.send_interval` starts when a live non-SSE request enters the Plug path (`serve_shape_response/2` or `serve_shape_log/2`) - A `register_before_send` callback cancels the timer and flushes stale messages when the response is sent - The keepalive callback is stored as a closure (`on_keepalive`) on the `Request` struct, keeping `Plug.Conn` out of the domain struct - `hold_until_change` is split into two functions: the outer sets up a `Process.send_after` timeout timer (replacing `receive...after` which would reset on keepalive re-entry), the inner `do_hold_until_change` handles the receive loop with a new `:long_poll_keepalive` clause - Keepalive interval is `div(long_poll_timeout, 4)` clamped to 5–15 seconds ## Alternatives considered ### Chunked transfer encoding with whitespace keepalive bytes Send `Transfer-Encoding: chunked` immediately and emit `" "` (space) chunks as keepalive during the hold, then send the real JSON payload as the final chunk. **Rejected for two reasons:** 1. **Breaks backwards compatibility.** HTTP headers are committed when chunked encoding starts, before the hold resolves. The `electric-offset` header would be stale when new data arrives during the hold. This requires a TypeScript client change (using body-based offset instead of header-based) to avoid an infinite re-fetch loop — breaking old clients on the new server. 2. **Breaks CDN request collapsing.** Live long-poll responses are cacheable (`Cache-Control: public, max-age=5, stale-while-revalidate=5`). With the current non-chunked approach, CDNs like Cloudflare hold the coalescing window open for the full hold duration — multiple clients requesting the same shape+offset are collapsed into one origin request. Starting a chunked response immediately closes this window on Cloudflare and CloudFront because the response is already "in flight." With 102, the coalescing window stays open since 1xx responses are not final responses. ### Stream.resource pattern (modeled on existing SSE keepalive) Replace `hold_until_change` entirely with a `Stream.resource` that emits keepalive chunks and data chunks as a streaming response body. **Rejected because** it changes the response semantics: the `Response` struct fields (`offset`, `up_to_date`, `status`) are frozen at stream creation time rather than set after the hold resolves. This broke 11 existing tests and required changing error behavior (shape rotation, out-of-bounds, stack failure all became 200 with empty body instead of their proper status codes). Also has the same CDN collapsing and backwards-compatibility issues as the chunked approach. ### Shorter long-poll timeout Reduce `long_poll_timeout` to well under the middlebox timeout. **Rejected because** it doubles the request rate for idle shapes without solving the root cause. ## On HTTP 102 Processing `102 Processing` was defined in RFC 2518 (WebDAV, 1999) specifically for preventing client timeouts on long-running requests — the exact use case here. It was removed in RFC 4918 (2007) with the stated reason: **"due to lack of implementation"** — not because it was harmful or architecturally unsound. MDN labels 102 as "deprecated," but this is an editorial judgment, not a standards-body action. No RFC has ever formally deprecated 102. The status is more accurately described as "no longer defined by any active RFC" — a state shared by many widely-used status codes (429 Too Many Requests was also defined outside RFC 9110's predecessor until recently). ### Why it's safe to use - **RFC 9110 §15.2 requires** all HTTP/1.1+ clients to parse unknown 1xx responses and allows ignoring them — sending 102 cannot break spec-compliant implementations - **RFC 9110 §15.1 explicitly acknowledges** status codes "outside the scope of this specification" as legitimate, provided they are IANA-registered - **102 is permanently registered** in the [IANA HTTP Status Code Registry](https://www.iana.org/assignments/http-status-codes) with no deregistration attempts - **Cloudflare explicitly supports and recommends it** for keepalive: ["If Cloudflare receives a 102 Processing response, it expects a final response within 120 seconds"](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/1xx-informational/) - **All major proxies forward it**: nginx, HAProxy, Envoy (since [envoyproxy/envoy#19023](envoyproxy/envoy#19023)) - **HTTP/2 (RFC 9113 §8.8.5)** explicitly handles 1xx informational responses including 102 - **Bandit supports it** natively via `Plug.Conn.inform/2`; **Node.js** has `response.writeProcessing()` since v10; **Go** added 1xx support in Go 1.19 - **No other 1xx code fits**: `100 Continue` is for request bodies, `103 Early Hints` is for resource preloading and would confuse browsers ### Known limitations - **Go's `net/http`** has a default limit of 5 consecutive 1xx responses. Our 3–4 responses per hold (at 5s intervals over 20s) are within this limit. - **AWS ALB** may silently drop 1xx responses — this is harmless since ALB's idle timeout (default 60s, configurable up to 4000s) already exceeds typical long-poll durations. - **Spring Framework 7.0** deprecated the `HttpStatus.PROCESSING` enum constant. This is the only major framework taking action, and it's the constant, not the protocol behavior. ## CDN request collapsing Electric's live long-poll responses are cacheable (`Cache-Control: public, max-age=5, stale-while-revalidate=5`), which enables CDN request collapsing — multiple clients requesting the same shape+offset are collapsed into a single origin request. The 102 approach preserves this because 1xx informational responses are not final responses. The CDN continues to hold the coalescing window open until the final 200 arrives. This is significant under high concurrency where many clients subscribe to the same shape. By contrast, the alternative chunked-whitespace approach would close the coalescing window immediately by committing a 200 response before the hold resolves. ## Test plan - [x] All 51 existing `api_test.exs` tests pass with no modifications - [x] All 311 TypeScript client unit tests pass with no modifications - [ ] Integration test with real HTTP server verifying 102 responses arrive on the wire - [ ] Manual verification against Cloudflare-fronted deployment 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]> Co-authored-by: Ilia Borovitinov <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proxying 102s from upstream
Risk Level: Low (minor refactor)
Testing: new integration test
Docs Changes: n/a
Release Notes: inline
Runtime guard: envoy.reloadable_features.proxy_102
Fixes #18844