Skip to content

feat(server): add cooperative request cancellation and deadlines - #253

Merged
andrewzolotukhin merged 1 commit into
developmentfrom
feat/request-cancellation
Oct 17, 2026
Merged

andrewzolotukhin merged 1 commit into
developmentfrom
feat/request-cancellation

Conversation

@andrewzolotukhin

@andrewzolotukhin andrewzolotukhin commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

Request handlers need a reusable way to cancel cooperative work when the client disconnects, a deadline expires, or a caller cancels. withRequestSignal(context, work, { timeoutMs, signal? }) provides that lifecycle and releases its timer/listeners whenever work settles. Deadline policy remains with the application, and normal response completion does not produce a false disconnect.

Original request

Move reusable request-owned cancellation/deadline handling into Framework, with documentation and a unit-test safety net.

What changed

  • Added the exported helper and structural context/options types.
  • Preserve caller abort reasons; use AbortError for disconnect and TimeoutError for deadlines; never start already-cancelled work.
  • Document cooperative behavior, lifecycle cleanup, deadline bounds and HTTP policy boundaries in JSDoc and the package README.
  • Added a minor changeset and 17 focused cases.

Reasoning

A scoped helper makes the lifetime explicit without changing handler types, HTTP statuses, or application timeout defaults. It does not race arbitrary work that would continue performing effects after rejection.

Type of Change

  • New feature
  • Documentation update

Blog post

Skipped: internal server infrastructure API; the package README and JSDoc document the feature.

Screenshots / preview evidence

Not applicable: this adds a non-visual server helper with no demo route or UI change. Real HTTP lifecycle objects are exercised in unit tests. Consumer preview verification belongs to its integration PR.

Validation

  • npm run lint, npm run build, npm run test: pass.
  • Full suite: 298 files, 5,355 tests, no type errors.
  • npm run test:coverage: all published-package floors pass; the new helper has 100% lines/statements/functions/branches.
  • CI run: all required jobs pass, including lint/build/test/coverage/package checks, PostgreSQL integration, Garage storage, and demo API/browser/telemetry E2E.

Checklist

  • Added tests
  • Ran lint
  • Ran build and test
  • Added a changeset

@andrewzolotukhin
andrewzolotukhin merged commit ec5b1c3 into development Oct 17, 2026
5 checks passed
@andrewzolotukhin
andrewzolotukhin deleted the feat/request-cancellation branch October 17, 2026 11:31
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