Repository navigation
Conversation
Contributor
|
@launchdarkly/js-sdk-common size report |
Contributor
|
@launchdarkly/js-client-sdk-common size report |
Contributor
|
@launchdarkly/js-client-sdk size report |
joker23
marked this pull request as ready for review
October 9, 2026 16:52
joker23
marked this pull request as draft
October 9, 2026 17:51
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.
Summary
Extends the platform
Requeststypes in@launchdarkly/js-sdk-commonso a platformfetchimplementation can serve as the SSE streaming transport for@launchdarkly/eventsourcethrough structural typing, with no dependency between the two packages in either direction.New members on the platform types, all optional so existing platform implementations remain valid and external implementers see no breaking change:
Options.streaming-- marks a streaming request: the implementation does not request compressed content, applies no request timeout, and delivers response chunks with low latency through the response body.Options.signal-- anAbortSignalLikeabort signal. The type resolves to the platform's own globalAbortSignalwhen one is declared, and falls back to a minimal structural subset otherwise, which keeps the published declarations valid for consumers that compile without DOM or Node global types.Response.statusTextandResponse.body(with the newResponseBodyandBodyReaderinterfaces) -- the streamable response surface.Headers.forEach-- the header iteration the streaming client reads.On the eventsource side,
FetchLikeResponse.statusTextandFetchHeaders.forEachbecome optional, so the contract --Requests['fetch']is assignable toFetchLike-- holds at the interface level. The client already guarded a missingstatusTextat runtime;headersToObjectgains the matching guard for a missingforEach. Compile-level assertions in the eventsource type-compatibility tests enforce the contract and pin its two deliberate exceptions (credentialsandurl). Note for external consumers of@launchdarkly/eventsource: the read type ofstatusTextwidens tostring | undefined, andFetchHeaders.forEachbecomes optional, so code that reads these members directly must guard them.The Shopify Oxygen implementation converts the platform options at its native
fetchboundary, because its test configuration declaresRequestInitwithout a globalAbortSignalconstructor.No runtime behavior changes beyond the header guard: a transport that supplies no header iteration now reports an empty header set instead of failing the stream as unreadable. This is a deliberate decision, and it follows the existing rule that a 200 response with no Content-Type header is accepted, because a minimal transport can report no headers. The cost is that a transport which forgets
forEachloses Content-Type validation on a 200 rather than failing loudly.This is the bottom of a two-PR stack. #2060 moves the node-family SDKs' streaming transports onto this seam and deletes their parallel fetch adapters.
Note
Overview
Extends the shared platform
Requests/Options/Responsetypes so a platformfetchcan act as the SSE transport for@launchdarkly/eventsourcewithout a package dependency: optionalstreaming,signal(AbortSignalLike), responsebody/BodyReader, optionalstatusText, and optionalHeaders.forEach.On the eventsource side,
FetchHeaders.forEachandstatusTextare optional to match;headersToObjectnow treats missingforEachas an empty header set (200 streams can open without Content-Type validation). Compile-time checks intypeCompatibility.test.tslockRequests['fetch']↔FetchLikeassignability (with documented exceptions forcredentialsandurl).Adds
internal.toRequestInitand wires Shopify Oxygen to pass platform options through it at nativefetch/Requestboundaries forAbortSignaltyping. New tests cover transports without header iteration orstatusText.Reviewed by Cursor Bugbot for commit ab84b96. Bugbot is set up for automated code reviews on this repo. Configure here.