refactor(functions): migrate Functions to HTTPRuntime#1116
Draft
grdsdev wants to merge 13 commits into
Draft
Conversation
Coverage Report for CI Build 29159794086Coverage decreased (-0.03%) to 83.524%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions3 previously-covered lines in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
…Runtime Switches Functions off Helpers.HTTPClient/HTTPRequest/HTTPResponse and onto HTTPRuntime for headers (HTTPFields -> [String: String]) and the buffered invoke/invoke(decode:)/invoke(decoder:) path, via a private FetchHandlerTransport adapter wrapping the existing fetch: closure as an HTTPTransport. Also fixes client.functions.headers.dictionary in SupabaseClientTests (now already [String: String]) to keep the package building. Streaming (_invokeWithStreamedResponse) gets a one-line stopgap and is fully migrated in a follow-up.
…ientOptions + HTTPTransport Introduce FunctionsClientOptions and an injectable HTTPTransport as the primary construction path, moving the legacy fetch:-closure initializers to deprecated back-compat shims in Deprecated.swift. FetchHandlerTransport's stream() now delegates to a real URLSessionTransport instead of being unreachable.
Contributor
|
test(functions): fix FunctionsClientTests for new options/transport API Adds missing DocC comments on FunctionsClientOptions and the primary init(url:options:), and updates the Topics outline to reference the current public API instead of the initializer now in Deprecated.swift. Test fixes: drop the removed sessionConfiguration: argument in favor of the transport-based init, add missing try await on _invokeWithStreamedResponse call sites, and fix two relay-error tests that mocked a 2xx status — relay-error detection only runs on non-2xx responses by design, so those mocks now use a non-2xx status code.
…tIssue Un-reverts the FetchHandlerTransport change from the docs pass: send/stream use plain throws (no HTTPError.transport re-wrapping), and send reports an issue when uploadProgress is set, since the fetch: closure has no way to honor it.
Whole-branch review turned up regressions from the HTTPRuntime migration: - HTTPRequest gains a generic `timeout` field, applied by URLSessionTransport.makeURLRequest. FunctionsClient.buildRequest sets it to requestIdleTimeout on every request, so the 150s gateway timeout applies uniformly again (previously only the deprecated FetchHandlerTransport path set it, so the new init(url:options:) path silently fell back to URLSession's default ~60s timeout). This also lets FetchHandlerTransport drop its duplicate makeURLRequest override. - _invokeWithStreamedResponse now wraps the returned body stream so mid-stream transport failures unwrap HTTPError.transport to the underlying error, matching the buffered rawInvoke path instead of leaking a package-internal error type to callers. - Deprecated.swift gets the standard file header used by every sibling file in Sources/Functions and Sources/HTTPRuntime. - Fixes a stale doc comment claiming the package init(url:options:transport:) is used by SupabaseClient (it still uses the deprecated initializer).
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
Stacked on #1121. Migrates
Sources/Functionsto use the newHTTPRuntimetarget internally instead ofURLSessiondirectly, and reworksFunctionsClient's public construction API around an injectableHTTPTransport.invoke/streaming paths route throughHTTPTransport.send/stream(backed byHTTPRuntime.URLSessionTransportby default).FunctionsClientOptions(headers/region/logger/decoder/session) plusFunctionsClient.init(url:options:)become the primary public construction API.fetch:-closure initializers move toSources/Functions/Deprecated.swiftas@available(*, deprecated)back-compat shims, adapted toHTTPTransportviaFetchHandlerTransport(buffered send goes through the customfetch:closure; streaming falls back to a plainURLSessionTransport, since afetch:closure can't stream).HTTPRequestgains a generictimeoutfield (consumed byURLSessionTransport.makeURLRequest) soFunctionsClient.requestIdleTimeout(150s) applies uniformly across every transport/path, instead of only the deprecated fetch-closure path._invokeWithStreamedResponse's returned body stream unwrapsHTTPError.transporton mid-stream failures, matching the buffered path's error surface instead of leaking a package-internal error type.Test plan
swift buildswift test --filter FunctionsClientTests(16 tests)swift test(full suite, 124 tests, 0 failures)./scripts/format.sh(no changes)