Skip to content

fix: handle AbortSignal cancellation rejections - #1322

Merged
Borewit merged 1 commit into
masterfrom
fix/abort-rejection
Oct 11, 2026
Merged

Borewit merged 1 commit into
masterfrom
fix/abort-rejection

Conversation

@Borewit

@Borewit Borewit commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Resolves a process crash when an AbortSignal fires after a web stream has errored: cancellation can reject even after the caller handles the read error.

Handle rejections from signal-triggered aborts while preserving cancellation errors for callers that explicitly await abort() or close(). Always release the default web stream reader lock in finally, including when cancellation fails.

Summary by CodeRabbit

  • Bug Fixes
    • Aborting an errored stream no longer causes an unhandled rejection.
    • Closing a stream releases its lock even if cancellation fails. Explicit aborts continue to report cancellation errors.

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: Borewit/strtok3/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9860dc62-9dc8-44a1-820f-ec79fbaa6269

📥 Commits

Reviewing files that changed from the base of the PR and between 99872f9 and 445ee7e.


📒 Files selected for processing (3)
  • lib/AbstractTokenizer.ts
  • lib/stream/WebStreamDefaultReader.ts
  • test/test.ts

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



📝 Walkthrough

Walkthrough

Signal-triggered aborts now catch cancellation rejection. The Web stream reader releases its lock when cancellation rejects. New tests cover signal-triggered aborts, close-time cancellation rejection, and explicit abort rejection.

Changes

Web stream cancellation handling

Layer / File(s) Summary
Signal-triggered abort handling
lib/AbstractTokenizer.ts, test/test.ts
The abort-signal listener catches rejection from abort(). A child-process test checks the behavior under strict unhandled-rejection handling.
Reader lock release during cancellation
lib/stream/WebStreamDefaultReader.ts, test/test.ts
close() releases the reader lock in a finally block. Tests verify lock release when cancellation rejects and verify that explicitly awaited abort() still rejects.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix


Merge Risk | ⚪ Minimal · up to 445ee

Merge Risk: ⚪ Minimal · up to 445ee

No actionable merge-blocking risk is identified for the Web-stream cancellation change; it is mergeable after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 445ee

The change improves cancellation failure handling and reader cleanup without adding new entrypoints or privileges. No introduced security concern was established, but overlapping lifecycle calls and cancellation failure during a pending read remain incompletely verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated failure boundary is the consuming process and its reader for a supplied Web stream. Whether an attacker can induce the stream error and whether that process serves multiple tenants depend on the consuming application; those deployment exposures are not established here.

Trust Boundaries and Controls

  • observed — The rejection handler is limited to the signal listener. Explicit abort and close delegation does not catch cancellation errors, so the change does not convert explicitly awaited cancellation failure into reported success.

Resilience and Maintainability Implications

  • observed — Cleanup now has a finally path after cancellation settles, improving failure containment for a rejecting cancellation. It does not add lifecycle serialization, an idempotency guard, or a recovery reset. Those omissions predate the PR and are not established as introduced security concerns.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: handling cancellation rejections triggered by AbortSignal.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR


🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@Borewit Borewit self-assigned this Oct 11, 2026
@Borewit Borewit added the bug Existing functionality behaves incorrectly or produces unexpected results. label Oct 11, 2026
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 93.339% (+0.1%) from 93.225% — fix/abort-rejection into master

@Borewit
Borewit merged commit 02c2088 into master Oct 11, 2026
29 checks passed
@Borewit
Borewit deleted the fix/abort-rejection branch October 11, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Existing functionality behaves incorrectly or produces unexpected results.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants