Skip to content

Conversation

@deblasis
Copy link

@deblasis deblasis commented Nov 30, 2025

Problem

The current implementation attempts to instantiate AbortSignal directly using new AbortSignal()

This is incorrect because AbortSignal is an internal web API constructor and cannot be instantiated by user code (it throws a TypeError: Illegal constructor in most environments). The correct way to obtain a signal is via an AbortController instance.

Repro

I encountered the issue while working on a Tanstack Start project with nitro and ws.

https://github.com/deblasis/tanstack-start-crossws-bug/tree/fix

Reference

https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal

Summary by CodeRabbit

  • Refactor
    • Updated internal request signal initialization to a different construction path while preserving public behavior and interfaces.
    • No changes to exported signatures or user-facing functionality; existing integrations continue to work as before.

This release contains internal implementation improvements with no user-facing changes.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 30, 2025

📝 Walkthrough

Walkthrough

Lazy initialization of the _signal property in src/_request.ts now creates an AbortController and uses its .signal instead of instantiating an AbortSignal directly; public APIs and signatures remain unchanged. (50 words)

Changes

Cohort / File(s) Change Summary
Signal initialization refactor
src/_request.ts
Replaced direct AbortSignal creation with new AbortController().signal for _signal lazy initialization. No exported signatures changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Areas requiring attention:
    • Verify behavior parity of the returned AbortSignal compared to prior implementation.
    • Check for any lifecycle or timing differences introduced by creating an AbortController.
    • Confirm there are no unintended retained references affecting garbage collection.

Poem

🐇 I nudged a signal from a tidy little den,
A controller hummed softly and out it leapt then.
Quiet mechanics, the surface stays clear,
A rabbit-approved tweak — hop on, no fear! 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix signal getter to use AbortController' directly and clearly summarizes the main change: correcting the signal getter implementation to properly use AbortController instead of directly instantiating AbortSignal.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 13d77ae and f4abfa0.

📒 Files selected for processing (1)
  • src/_request.ts (1 hunks)
🔇 Additional comments (1)
src/_request.ts (1)

31-32: Correct lazy initialization of signal via AbortController

This getter now correctly derives the AbortSignal from new AbortController().signal and caches it via ??=, eliminating the illegal direct AbortSignal construction while still returning a stable signal per instance.

Please confirm that all supported runtimes expose a global AbortController (or have an appropriate polyfill); otherwise this could throw a ReferenceError in older/non‑DOM environments.


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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 440a088 and 13d77ae.

📒 Files selected for processing (1)
  • src/_request.ts (1 hunks)
🧰 Additional context used
🪛 Biome (2.1.2)
src/_request.ts

[error] 32-32: expected ) but instead found ;

Remove ;

(parse)

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