Skip to content

fix(utils): type async request methods as coroutines and test cancelling them - #2112

Merged
spydon merged 2 commits into
mainfrom
lukasklingsbo/sdk-2781-functions-test-that-cancelling-invoke
Nov 17, 2026
Merged

spydon merged 2 commits into
mainfrom
lukasklingsbo/sdk-2781-functions-test-that-cancelling-invoke

Conversation

@spydon

@spydon spydon commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Tests that cancelling the task awaiting invoke() or invoke_stream() aborts the request and frees its connection. SDK-2781

  • aiohttp and httpx, against a local server with a one connection pool, so a leaked connection makes the next call time out.
  • Covers cancelling mid-request (the server sees the disconnect) and while AsyncHttpIO waits between retries (no retry is sent).
  • handle_http_io methods are now typed as returning a Coroutine instead of an Awaitable, so asyncio.create_task(client.invoke(...)) type checks.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Added coverage for cancelling asynchronous requests during active calls and retry delays, including checks that cancellation stops further requests and leaves connections available.
  • Developer Experience
    • Improved the precision of async return type information for HTTP operations, making it clearer to type checkers and developers that these operations return coroutines.

The pull request adds cancellation tests for AsyncFunctionsClient using aiohttp and httpx sessions. The tests cover cancellation during a hanging request and during a retry delay, for buffered and streaming invocations. They check that cancellation propagates and that a connection remains available afterward. The pull request also changes asynchronous return annotations in handle_http_io.__get__ from Awaitable to Coroutine.

Possibly related PRs

Change: Other

Merge Risk: Minimal · up to e3f48

This change adds tests for cancelling async function invocations and adjusts type annotations so that wrapping calls in asyncio.create_task type-checks. It does not change runtime behavior, so the merge risk is minimal.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 857ed687-c727-4d50-b9f4-e8800dc4b467
Commits

Reviewing files that changed from the base of the PR and between 76d87d4 and e3f482c.

Files selected for processing: 2

  • src/functions/tests/_async/test_cancellation.py
  • src/utils/src/supabase_utils/http/io.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@spydon spydon changed the title test(functions): cover cancelling invoke() on both async adapters fix(utils): type async request methods as coroutines and test cancelling them Nov 17, 2026
@spydon
spydon merged commit e849e5e into main Nov 17, 2026
53 checks passed
@spydon
spydon deleted the lukasklingsbo/sdk-2781-functions-test-that-cancelling-invoke branch November 17, 2026 15:08
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