Skip to content

Conversation

@kixelated
Copy link
Collaborator

@kixelated kixelated commented Sep 4, 2025

Summary by CodeRabbit

  • Refactor

    • Moved delay/headstart handling into the connection layer to centralize logic and reduce duplication.
    • Connection fallback flow streamlined for clearer control and consistent enforcement of configured delays.
    • Improved responsiveness to cancellation via a timer-based gate before attempting fallback.
    • Added clearer runtime messages when falling back after a configured delay.
    • Public API unchanged.
  • Chore

    • Package version bumped to 0.8.2.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 4, 2025

Walkthrough

Refactors WebSocket fallback by moving headstart delay and cancellation gating into connectWebSocket (now accepts a delay). Adds Promise.race-based preflight to abort if canceled before delay, logs when delayed fallback runs, and simplifies outer connect() while preserving zero-delay behavior.

Changes

Cohort / File(s) Summary
WebSocket fallback refactor
js/moq/src/connection.ts
Centralizes headstart logic inside connectWebSocket; signature changes to (url, delay, cancel). Adds a timer-based preflight using Promise.race([cancel, timer]) to abort early, returns undefined if canceled, and logs when delay > 0. Streamlines outer connect() race between WebTransport and WebSocket.
Package version bump
js/moq/package.json
Increments package version from 0.8.1 to 0.8.2. No other fields changed.

Sequence Diagram(s)

sequenceDiagram
    participant App as Caller
    participant Conn as connect()
    participant WT as WebTransport
    participant WS as connectWebSocket(delay,cancel)

    App->>Conn: connect(url, headstart)
    par WebTransport attempt
        Conn->>WT: start WT connection
        WT-->>Conn: success or failure
    and WebSocket fallback (delayed)
        Conn->>WS: start with delay=headstart, cancel
        WS->>WS: Promise.race(cancel, timer(delay))
        alt canceled before delay
            WS-->>Conn: return undefined
        else delay elapsed
            WS->>WS: initiate WebSocket connect
            WS-->>Conn: WS result (success/failure)
        end
    end
    alt First successful transport
        Conn-->>App: return transport
    else Both fail / canceled
        Conn-->>App: propagate failure/undefined
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

I twitched my whiskers at the race,
WT sprints, WS keeps pace.
A tiny pause, a timed gate click—
If cancel wins, we burrow quick.
But when delay says “hop, now go,”
We weave the webs and make it so. 🐇🧵


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7f240fb and 5a4c229.

📒 Files selected for processing (1)
  • js/moq/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • js/moq/package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Check
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch remove-log

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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

🧹 Nitpick comments (1)
js/moq/src/connection.ts (1)

169-173: Gating logic is correct; tiny naming nit.

active holds a truthy “proceed” flag (boolean|void). Consider renaming for clarity.

-  const active = await Promise.race([cancel, timer.then(() => true)]);
-  if (!active) return undefined;
+  const proceed = await Promise.race([cancel, timer.then(() => true)]);
+  if (!proceed) return undefined;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e551fc4 and 7f240fb.

📒 Files selected for processing (1)
  • js/moq/src/connection.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
js/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place JS/TS packages under the js/ directory

Files:

  • js/moq/src/connection.ts
🔇 Additional comments (1)
js/moq/src/connection.ts (1)

65-65: connectWebSocket call sites verified
Search with rg -nP '\bconnectWebSocket\s*\(' js/ shows only the updated invocation at line 65 and the function definition at line 168—no stale call sites remain.

Comment on lines +174 to +176
if (delay) {
console.debug(url.toString(), `no WebTransport after ${delay}ms, attempting WebSocket fallback`);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove pre-connection fallback log to meet PR objective.

This debug line will log even when QUIC wins after the delay (fallback not used), which contradicts “Avoid logging the WebSocket fallback even if it's not being used.” The existing warn at Line 82 already logs when WebSocket actually wins.

-  if (delay) {
-    console.debug(url.toString(), `no WebTransport after ${delay}ms, attempting WebSocket fallback`);
-  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (delay) {
console.debug(url.toString(), `no WebTransport after ${delay}ms, attempting WebSocket fallback`);
}
// – if (delay) {
// – console.debug(url.toString(), `no WebTransport after ${delay}ms, attempting WebSocket fallback`);
// – }
🤖 Prompt for AI Agents
In js/moq/src/connection.ts around lines 174-176, remove the pre-connection
debug log that prints a fallback message after the delay; this log can fire even
when QUIC succeeds and contradicts the PR objective. Either delete those two
lines entirely or move the logging so it only executes in the actual
WebSocket-fallback branch (the same place where the existing warn at line 82
logs when WebSocket wins), ensuring no fallback message is emitted unless
WebSocket is actually used.

@kixelated kixelated enabled auto-merge (squash) September 4, 2025 22:57
@kixelated kixelated merged commit 0fb4823 into main Sep 4, 2025
2 checks passed
@kixelated kixelated deleted the remove-log branch September 4, 2025 23:12
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.

2 participants