Skip to content

fix(functions): honor pre-aborted signals with timeout - #2649

Open
hsusul wants to merge 1 commit into
supabase:masterfrom
hsusul:fix/functions-preaborted-timeout
Open

fix(functions): honor pre-aborted signals with timeout#2649
hsusul wants to merge 1 commit into
supabase:masterfrom
hsusul:fix/functions-preaborted-timeout

Conversation

@hsusul

@hsusul hsusul commented Sep 1, 2026

Copy link
Copy Markdown

🔍 Description

What changed?

  • Immediately abort the internal timeout controller when invoke() receives an already-aborted caller signal.
  • Keep the existing listener forwarding and cleanup behavior for signals that abort after invocation starts.
  • Add a regression test through FunctionsClient.invoke().

Why was this change needed?

When both timeout and signal are supplied, invoke() replaces the caller signal with a fresh controller and registers an abort listener. Registering that listener after the caller signal has already aborted does not replay the event, so the request could execute with an active signal.

Closes #2648

📸 Screenshots/Examples

Not applicable.

🔄 Breaking changes

  • This PR contains no breaking changes

📋 Checklist

  • I have read the Contributing Guidelines
  • My PR title follows the conventional commit format
  • I have run formatting checks
  • I have added regression tests
  • Documentation is unchanged because the public API and documented behavior do not change

🧪 Validation

  • pnpm --dir packages/core/functions-js exec jest FunctionsClient.test.ts --runInBand — 3 passed
  • pnpm nx test functions-js — 43 passed, 1 existing skip
  • pnpm nx build functions-js — passed
  • pnpm exec prettier --check packages/core/functions-js/src/FunctionsClient.ts packages/core/functions-js/test/FunctionsClient.test.ts — passed
  • git diff --check — passed

Package-wide lint currently reports 12 pre-existing errors on the untouched base revision; targeted lint reproduces the same existing errors in FunctionsClient.ts and reports no new test-file findings.

@hsusul
hsusul requested review from a team as code owners September 1, 2026 19:49
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: b7f05716-55d8-492f-a330-c9ec120338e9

📥 Commits

Reviewing files that changed from the base of the PR and between b3b939a and 236545a.

📒 Files selected for processing (2)
  • packages/core/functions-js/src/FunctionsClient.ts
  • packages/core/functions-js/test/FunctionsClient.test.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved request cancellation when an already-aborted signal is used with a configured timeout.
    • Ensured requests fail promptly and correctly honor the caller’s cancellation state.
  • Tests

    • Added coverage for requests using an already-aborted signal alongside a timeout.

Walkthrough

FunctionsClient.invoke now checks a caller-provided signal before adding the timeout abort listener. If the signal is already aborted, the timeout controller is aborted immediately. Otherwise, the existing listener behavior remains unchanged. A regression test verifies that fetch receives an aborted signal, runs once, and returns an error.

Assessment against linked issues

Objective Addressed Explanation
Handle an already-aborted caller signal when invoke receives a positive timeout [#2648]

Merge Risk: ⚪ Minimal · up to 23654

The change ensures already-aborted signals cancel invocations immediately when a timeout is configured while preserving existing request behavior; no actionable merge-blocking risk remains after normal checks and review.


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

Comment @coderabbitai help to get the list of available commands.

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.

Functions invocation ignores pre-aborted signal when timeout is set

1 participant