Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix web FetchRequest does not respect disableConnectivityCheck client option #1925

Merged
merged 2 commits into from
Jan 23, 2025

Conversation

VeskeR
Copy link
Contributor

@VeskeR VeskeR commented Nov 22, 2024

See internal slack thread for more context.

Summary by CodeRabbit

  • New Features

    • Enhanced connectivity check functionality, allowing for immediate success when the disableConnectivityCheck option is enabled.
  • Bug Fixes

    • Improved error handling for unsupported HTTP transports.
  • Tests

    • Expanded test coverage for browser connectivity scenarios, including new cases for disabled fetch and XHR request implementations.

Copy link

coderabbitai bot commented Nov 22, 2024

Warning

Rate limit exceeded

@VeskeR has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 51 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between f4acc4a and 5cdeddc.

📒 Files selected for processing (2)
  • src/platform/web/lib/http/http.ts (1 hunks)
  • test/browser/connection.test.js (2 hunks)

Walkthrough

The changes in this pull request modify the checkConnectivity method within the Http class located in src/platform/web/lib/http/http.ts. The method now includes a conditional check for a disableConnectivityCheck option, altering its behavior based on this setting. Additionally, the connection.test.js file is updated to enhance testing for browser connectivity scenarios, incorporating new test cases that evaluate the connectivity checks when fetch and XHR implementations are disabled. The overall structure and public interface of the Http class remain unchanged.

Changes

File Path Change Summary
src/platform/web/lib/http/http.ts Modified checkConnectivity method to include a conditional check for disableConnectivityCheck. Ensured consistent behavior for both XHR and FetchRequest implementations.
test/browser/connection.test.js Added Ably module dependency and new test cases for connectivity checks when fetch and XHR are disabled. Enhanced overall test structure.

Possibly related PRs

Suggested reviewers

  • owenpearson
  • ttypic

Poem

🐰 In the web's vast, hopping space,
Connectivity checks now find their place.
With options set, they dance and play,
Fetch and XHR lead the way.
Tests now flourish, robust and bright,
Ensuring our paths stay clear and right! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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

Documentation and Community

  • 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.

@github-actions github-actions bot temporarily deployed to staging/pull/1925/bundle-report November 22, 2024 11:33 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1925/typedoc November 22, 2024 11:33 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1925/features November 22, 2024 11:33 Inactive
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: 3

🧹 Outside diff range and nitpick comments (1)
test/browser/connection.test.js (1)

458-458: Clarify the comment for better readability

The comment could be rephrased to more explicitly explain the purpose of these tests and how they differ from existing ones.

Suggested change:

- // this is identical to disable_connectivity_check test in connectivity, but here we specifically test browser supported request implementations
+ // Similar to the 'disable_connectivity_check' test in 'connectivity', but specifically testing browser-supported request implementations (XHR and Fetch)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 18a2559 and f4acc4a.

📒 Files selected for processing (2)
  • src/platform/web/lib/http/http.ts (1 hunks)
  • test/browser/connection.test.js (2 hunks)
🔇 Additional comments (3)
src/platform/web/lib/http/http.ts (2)

121-124: LGTM: Proper implementation of disableConnectivityCheck option

The implementation correctly respects the disableConnectivityCheck client option by immediately returning true when enabled, consistent with the XHR implementation.


120-138: Verify test coverage for connectivity checks

Let's ensure that the test suite adequately covers both XHR and Fetch implementations, particularly for custom connectivity check URLs.

✅ Verification successful

Let me gather more information about the test implementations to ensure proper coverage.


Let me check the actual test cases for both success and failure scenarios to ensure complete coverage.


Test coverage for connectivity checks is comprehensive

The test suite adequately covers all aspects of the connectivity check implementation:

  • Tests for both success and failure scenarios with custom URLs
  • Coverage for disableConnectivityCheck option
  • Specific tests for both XHR and Fetch implementations
  • Tests for connectivity check with different URL configurations

The changes in the connectivity check implementation are well-supported by existing tests.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for connectivity check related tests
echo "Searching for connectivity check related tests..."
rg -l "connectivityCheck|checkConnectivity" test/

# Search for custom URL configurations in tests
echo "Searching for custom connectivity URL configurations in tests..."
rg "connectivityCheckUrl" test/

Length of output: 1319


Script:

#!/bin/bash
# Check the connectivity test implementations
echo "Checking connectivity.test.js implementation:"
rg -A 10 "describe.*connectivity" test/realtime/connectivity.test.js

# Check transport test implementations
echo "Checking transport test implementations:"
rg -A 10 "describe.*connectivity" test/realtime/transports.test.js

# Check connection test implementations
echo "Checking connection test implementations:"
rg -A 10 "describe.*connectivity" test/browser/connection.test.js

# Look for disableConnectivityCheck usage in tests
echo "Checking disableConnectivityCheck usage:"
rg "disableConnectivityCheck" test/

Length of output: 2086


Script:

#!/bin/bash
# Check the specific test cases in connectivity tests
echo "Checking connectivity test cases:"
rg -B 2 -A 10 "it\(.*connectivity" test/realtime/connectivity.test.js

# Check the specific test cases in connection tests
echo "Checking connection test cases:"
rg -B 2 -A 10 "it\(.*connectivity" test/browser/connection.test.js

# Check for any XHR specific connectivity tests
echo "Checking XHR specific tests:"
rg -B 2 -A 10 "XHR.*connectivity|xhr.*connectivity" test/

Length of output: 2430

test/browser/connection.test.js (1)

3-3: Dependency Update: Added 'Ably' module to test dependencies

Including 'Ably' in the module dependencies ensures that the tests have access to Ably.Rest.Platform.Config, which is necessary for configuring and manipulating platform-specific settings in the new test scenarios.

src/platform/web/lib/http/http.ts Show resolved Hide resolved
test/browser/connection.test.js Show resolved Hide resolved
test/browser/connection.test.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@ttypic ttypic left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants