Repository navigation
feat: add configurable timeouts for emitters - #659
Open
kahirokunn wants to merge 8 commits into
Open
kahirokunn wants to merge 8 commits into
kahirokunn wants to merge 8 commits into
Conversation
Signed-off-by: kahirokunn <okinakahiro@gmail.com>
Signed-off-by: kahirokunn <okinakahiro@gmail.com>
Use the platform HTTP client in Node.js and browsers without importing
Node-only http and https modules into the SDK's public entry point.
Preserve CloudEvent serialization, URL credentials and per-send headers,
and expose transport-wide headers and Fetch request options.
Keep the transport result inferred through emitterFor(). HTTP status codes
still resolve at this point; delivery failure handling is a separate change.
BREAKING CHANGE: httpTransport() resolves with { response, body }, where
response is the native Fetch Response, instead of { body, headers }.
Node.js global HTTP agents no longer configure these requests; a Fetch
dispatcher configures proxies, client certificates and custom trust.
Signed-off-by: kahirokunn <okinakahiro@gmail.com>
Reject responses that did not accept the event and distinguish HTTP status failures from requests that never produced a response. Keep an unreadable body after a successful status separate from a failed delivery, so a caller does not resend an event the receiver has already accepted. Allow transport-wide and per-send response handlers, preserving their body types through emitterFor(). Include text and discard handlers and clean up the body after a handler fails. BREAKING CHANGE: non-2xx HTTP responses reject with HTTPTransportError. Successful responses resolve with either body or bodyError. Options.headers is checked by TypeScript, and built-in HTTP transport annotations use HTTPTransportFunction and HTTPEmitterFunction. Signed-off-by: kahirokunn <okinakahiro@gmail.com>
Combine transport-wide and per-send abort signals while fetching and handling a response. Preserve the first abort reason, support signals from another realm and detach subscriptions when the operation finishes. Keep the shared signal implementation in its final module so emitter wrappers can reuse it without moving transport code in a later feature. BREAKING CHANGE: Options.signal is checked as an AbortSignal. A cancelled HTTP request rejects with HTTPTransportError of kind aborted; a body failure after a successful status remains a successful delivery result. Signed-off-by: kahirokunn <okinakahiro@gmail.com>
Keep the HTTP transport single-attempt and let applications opt into retrying temporary failures with a reusable emitter wrapper. Preserve the event and send options across attempts, bound backoff waits and honor Retry-After for 429 and 503 responses. Default retries recognize temporary HTTP failures, while custom transports can supply their own predicate and delay. Aborted sends are not retried, and a per-send signal can interrupt the wait before another attempt. Signed-off-by: kahirokunn <okinakahiro@gmail.com>
Give each emitter invocation a configurable deadline and combine it with the caller's abort signal. Preserve transport result and option types, including per-send HTTP response handlers, and dispose timers and signal subscriptions when the invocation settles. The wrapped emitter must honor its signal. This feature is independent of retry behavior and does not change the built-in transport's default send. Signed-off-by: kahirokunn <okinakahiro@gmail.com>
Keep timeout and retry independently reviewable, then check their combined behavior when both wrappers are available. Restore the existing per-attempt timeout coverage and document both wrapper orders. Verify that a whole-delivery deadline interrupts retry backoff before a second attempt, preserving the timeout reason rather than resending. Signed-off-by: kahirokunn <okinakahiro@gmail.com>
kahirokunn
marked this pull request as ready for review
October 13, 2026 15:57
This branch has not been deployed
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.
Fixes: #564
Proposed Changes
Add configurable emitter timeouts with
withTimeout().Description
withTimeout()combines a per-call deadline with the caller's abort signal. InsidewithRetry(), each attempt gets a fresh timeout; outside it, one timeout covers all attempts and backoff. The default retry policy does not retry timed-out HTTP sends.Depends on #658.