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

Migrate from websocket to deprecated console domain #348

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

soundofspace
Copy link
Contributor

@soundofspace soundofspace commented Jan 8, 2025

Websockets were a nice workaround to solve the issues we had with runtime.enable, but it also introduced some new problems. Both fetch and websockets had problems with content security policies and some general websocket issues also.

This was fixed with:

  • Instead of sending data over websockets, send data over deprecated console domain. Problems that were seen with runtime domain are not a problem here (size limit seems to be very high so should not be a problem)
  • Instead of sending fetch to a special domain, send it to the current domain (never a problem with content security policies), but use a special url with a random secret. This can also be extended in the future if needed
  • Rework events so they are cleaner and can be extended in the future if needed

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a secret key mechanism for enhanced security and request management across browser contexts.
    • Added a new Console class to facilitate communication between injected scripts and the agent.
    • Expanded event handling capabilities with new internal request and console event types.
  • Changes

    • Removed WebSocket session handling and replaced it with a more streamlined console-based communication approach.
    • Updated network request interception logic to utilize the new secret key mechanism.
    • Simplified Content Security Policy settings to tighten security.
    • Modified proxy bypass settings for improved configuration.
  • Performance

    • Optimized internal request handling and event management.
  • Security

    • Implemented a new secret key generation method to prevent detection.
    • Tightened connection source restrictions.

Copy link

coderabbitai bot commented Jan 8, 2025

Walkthrough

The changes represent a significant refactoring of the agent's communication and networking architecture. The primary focus is on removing WebSocket-based communication and replacing it with a new console-based communication mechanism. A new secretKey is introduced across multiple components to enhance internal request handling and provide a mechanism for identifying internal traffic. The changes involve removing the WebsocketSession class, introducing a new Console class, and modifying network and context management to use the new approach.

Changes

File Change Summary
agent/main/lib/Agent.ts Added secretKey property initialized with a random string; updated constructor and createBrowserContext method to use secretKey.
agent/main/lib/Browser.ts Simplified proxy bypass settings by removing websocket.localhost; removed context.initialize() call.
agent/main/lib/BrowserContext.ts Added secretKey option; removed websocketSession property and related methods.
agent/main/lib/Console.ts New class for managing console-based communication between injected scripts and agent; includes methods for handling console messages.
agent/main/lib/DevtoolsSessionLogger.ts Removed WebSocket request filtering logic.
agent/main/lib/FrameOutOfProcess.ts Updated NetworkManager initialization to use secretKey.
agent/main/lib/FramesManager.ts Replaced WebSocket event handling with console-based callbacks; added console property and initialization.
agent/main/lib/NetworkManager.ts Removed websocketSession; added handling for secretKey in request logic.
agent/main/lib/Page.ts Updated NetworkManager initialization to use secretKey.
agent/main/lib/WebsocketSession.ts Entire file removed.
agent/main/lib/Worker.ts Updated NetworkManager initialization to use secretKey.
agent/mitm/handlers/RequestSession.ts Added secretKey to constructor and request interception logic.
specification/* Updated interfaces to support new console and network event handling; added new event types.

Poem

🐰 A Rabbit's Ode to Refactoring 🕸️

WebSockets fade, a new path unfurls,
Secret keys dance, as code gently swirls.
Console whispers replace the old chime,
Simplicity blooms, one line at a time.

Hop, hop, refactor! The rabbit's delight 🚀

Finishing Touches

  • 📝 Generate Docstrings

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.

@soundofspace soundofspace force-pushed the migrate-from-websocket-to-deprecated-console-domain branch from 9ca1024 to bb8ad29 Compare January 8, 2025 12:53
@soundofspace soundofspace marked this pull request as ready for review January 9, 2025 14:05
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: 5

🧹 Nitpick comments (9)
agent/main/lib/Browser.ts (1)

371-371: Consider follow-up changes for console domain migration

While removing the websocket bypass is a good start, consider reviewing the following areas as part of the websocket to console domain migration:

  1. Event handling methods (onAttachedToTarget, onTargetCreated, etc.)
  2. Communication protocols in DevtoolsSession
  3. Target attachment and detachment logic
agent/main/lib/Console.ts (3)

23-23: Missing Semicolon in Variable Declaration

On line 23, the variable separator is declared without a terminating semicolon. While TypeScript allows optional semicolons, it's a best practice to include them for consistency and to avoid potential issues.

Apply this diff to add the missing semicolon:

- private separator = ' --- '
+ private separator = ' --- ';

80-99: Error Handling in handleConsoleMessage Method

In the handleConsoleMessage method, exceptions might be silently caught and ignored, which can make debugging difficult.

Consider logging errors when they occur to aid in troubleshooting:

} catch (error) {
-   return;
+   this.logger.error('Error handling console message', { error });
+   return;
}

118-137: Inefficient Stringification of injectedScript Function

The method of stringifying injectedScript and performing string replacements can be brittle and hard to maintain. This approach may lead to errors if the function body contains strings that match the placeholders.

Consider refactoring to use template literals or embedding the variables directly without string replacements. For example:

function injectedScript(): void {
  const clientId = Math.random();
  const secretKey = '${this.secretKey}';
  const separator = '${this.separator}';

  // ... rest of the code ...

  console.debug(`${secretKey}${separator}${clientId}${separator}${serializedData}`);
}

Then, in injectCallbackIntoScript, use a template literal:

const wsScript = `(${injectedScript.toString()})();`;

This approach avoids the need for string replacements and reduces the risk of errors.

agent/main/lib/FramesManager.ts (3)

73-73: Initialization Order of console Property

The console property is initialized on line 73 after some event listeners are set up in the constructor. If any of these listeners rely on this.console, it may lead to undefined behavior.

Move the initialization of this.console before setting up event listeners that use it:

this.page = page;
//...
this.devtoolsSession = devtoolsSession;

bindFunctions(this);

// Initialize console before using it
this.console = new Console(devtoolsSession, this.page.browserContext.secretKey);

// Event listeners that use this.console
this.events.on(this.console, 'callback-received', this.onCallbackReceived);

// Other event listeners...

Line range hint 699-717: Error Handling in onCallbackReceived Method

In the onCallbackReceived method, if the callback for a given event name is not found, the function proceeds without handling the case. This might lead to unintentional behavior or silent failures.

Add error handling or logging when a callback is not registered:

if (callback) {
  await callback(event.payload, frame);
+ this.page.emit('page-callback-triggered', {
+   name: event.name,
+   frameId: frame.frameId,
+   payload: event.payload,
+ });
} else {
+ this.logger.warn('No callback registered for event', { eventName: event.name });
}

96-101: Possible Memory Leak with Event Subscribers

In the event subscription starting on line 96, an anonymous function is used without a reference, which may prevent proper unsubscription later.

Store the event handler in a variable to enable proper cleanup when needed.

this.internalRequestHandler = (event: IBrowserNetworkEvents['internal-request']) => {
  // ...
};

this.events.on(this.networkManager, 'internal-request', this.internalRequestHandler);

Ensure to clean up the event listener in the close method:

this.events.off(this.networkManager, 'internal-request', this.internalRequestHandler);
specification/agent/browser/IConsole.ts (2)

2-2: Inconsistent Typing of payload Property

In the IConsoleEvents interface, payload is typed as a string. However, elsewhere in the code, payload seems to be any type (e.g., deserialized JSON object).

Consider updating the type of payload to better reflect its usage:

- 'callback-received': { id: string; name: string; payload: string };
+ 'callback-received': { id: string; name: string; payload: any };

5-5: Typo in Type Definition

The ConsoleCallback type is defined but not used in the code. Additionally, it accepts name and payload as parameters, whereas in the onCallbackReceived method, only payload and frame are used.

Review the type definition and its usage to ensure consistency. If ConsoleCallback is intended to be used elsewhere, consider updating it accordingly.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 19de3ad and ba740cd.

📒 Files selected for processing (17)
  • agent/main/lib/Agent.ts (3 hunks)
  • agent/main/lib/Browser.ts (1 hunks)
  • agent/main/lib/BrowserContext.ts (4 hunks)
  • agent/main/lib/Console.ts (1 hunks)
  • agent/main/lib/DevtoolsSessionLogger.ts (0 hunks)
  • agent/main/lib/FrameOutOfProcess.ts (1 hunks)
  • agent/main/lib/FramesManager.ts (6 hunks)
  • agent/main/lib/NetworkManager.ts (3 hunks)
  • agent/main/lib/Page.ts (1 hunks)
  • agent/main/lib/WebsocketSession.ts (0 hunks)
  • agent/main/lib/Worker.ts (1 hunks)
  • agent/main/test/mitm.test.ts (1 hunks)
  • agent/mitm/handlers/RequestSession.ts (2 hunks)
  • specification/agent/browser/IBrowserNetworkEvents.ts (2 hunks)
  • specification/agent/browser/IConsole.ts (1 hunks)
  • specification/agent/browser/IWebsocketSession.ts (0 hunks)
  • timetravel/lib/MirrorNetwork.ts (1 hunks)
💤 Files with no reviewable changes (3)
  • agent/main/lib/DevtoolsSessionLogger.ts
  • agent/main/lib/WebsocketSession.ts
  • specification/agent/browser/IWebsocketSession.ts
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: Test chrome-latest (node 22; ubuntu-latest)
  • GitHub Check: Test chrome-latest (node 22; windows-latest)
  • GitHub Check: Test chrome-latest (node 20; windows-latest)
  • GitHub Check: Test chrome-latest (node 18; windows-latest)
  • GitHub Check: Test chrome-latest (node 22; windows-latest)
  • GitHub Check: Test chrome-latest (node 20; windows-latest)
  • GitHub Check: Test chrome-latest (node 18; windows-latest)
  • GitHub Check: Test chrome-latest (node 20; macos-13)
  • GitHub Check: Test chrome-latest (node 22; macos-13)
  • GitHub Check: Test chrome-latest (node 18; macos-13)
  • GitHub Check: Test chrome-latest (node 20; macos-13)
  • GitHub Check: Test chrome-latest (node 18; macos-13)
🔇 Additional comments (18)
agent/main/lib/Browser.ts (1)

371-371: Verify localhost connectivity after removing websocket.localhost bypass

The removal of websocket.localhost from the proxy bypass list aligns with the migration from websocket to console domain. However, we should verify that this change doesn't affect other localhost connections.

Let's check for any other websocket-related configurations that might need updating:

✅ Verification successful

Proxy bypass configuration change is correct

The removal of websocket.localhost from the proxy bypass list is consistent with the migration from websocket to console domain. The remaining <-loopback> configuration is sufficient for handling local connections.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining websocket configurations
echo "Searching for websocket configurations..."
rg -i "websocket" 

# Search for proxy bypass configurations
echo "Searching for proxy bypass configurations..."
rg "proxy-bypass-list"

Length of output: 43080

agent/main/lib/Console.ts (4)

23-23: Hardcoded Separator Might Conflict with Payload Content

The separator value ' --- ' is hardcoded and used to split and join strings. If the payload or other data contains this separator sequence, it could lead to malformed data during processing.

This issue was previously addressed, but please verify that the current implementation correctly handles cases where the separator might appear in the payload. If necessary, consider using a less likely sequence or escaping instances of the separator within the payload.

Also applies to: 71-74


129-134: 🛠️ Refactor suggestion

Improper Handling of Global Variables in Injected Script

The injected script defines callback but does not ensure it doesn't conflict with existing variables in the global scope.

Wrap the injected script in an immediately invoked function expression (IIFE) to avoid polluting the global namespace:

function injectedScript(): void {
+ (function() {
  // existing code...
+ })();
}

Alternatively, ensure variables are declared with const or let and scoped appropriately.

Likely invalid or redundant comment.


71-74: Potential Incompatibility with .replaceAll Method

The use of .replaceAll on lines 71-72 may cause compatibility issues in environments where String.prototype.replaceAll is not supported (e.g., older versions of Node.js or some browsers). To ensure broader compatibility, consider using .replace with a global regular expression.

Replace the .replaceAll calls with .replace and a global regex:

- .replaceAll('${this.secretKey}', this.secretKey)
- .replaceAll('${this.separator}', this.separator)
+ .replace(/\$\{this\.secretKey\}/g, this.secretKey)
+ .replace(/\$\{this\.separator\}/g, this.separator)

Please verify if the deployment environments support .replaceAll, and adjust accordingly.


121-122: Potential Issues with URL Parsing

On lines 121-122, constructing the URL using new URL(document.URL).origin may not handle all cases correctly, especially if the document.URL is modified or in different browsing contexts.

Ensure that document.location.origin is used instead for consistency:

- const url = `${new URL(document.URL).origin}/heroInternalUrl?secretKey=${this.secretKey}&action=registerConsoleClientId&clientId=${clientId}`;
+ const url = `${document.location.origin}/heroInternalUrl?secretKey=${this.secretKey}&action=registerConsoleClientId&clientId=${clientId}`;

Please verify if this change aligns with the intended functionality.

agent/main/lib/FramesManager.ts (1)

Line range hint 217-223: Potential Security Risk with Script Injection

In the addNewDocumentScript method, user-provided scripts are being injected into pages. This can pose security risks if the scripts are not properly sanitized or trusted.

[security_issue]

Ensure that only trusted scripts are injected, and consider sanitizing or validating the script parameter. If scripts are sourced from user input, implement restrictions or escape mechanisms to prevent cross-site scripting (XSS) vulnerabilities.

specification/agent/browser/IBrowserNetworkEvents.ts (1)

56-59: LGTM! Well-structured event interface for internal requests.

The new event type is appropriately designed for handling internal communication, replacing the websocket-based approach.

agent/main/lib/Worker.ts (1)

64-64: LGTM! Consistent with the migration strategy.

The change correctly integrates the new secretKey-based approach, replacing the websocket session.

timetravel/lib/MirrorNetwork.ts (1)

70-70: LGTM! CSP header correctly updated for console-based communication.

The Content-Security-Policy has been appropriately modified to remove websocket-related directives while maintaining security with 'self' for connect-src.

agent/mitm/handlers/RequestSession.ts (1)

76-76: LGTM: New secretKey parameter added to support internal request handling.

The addition of the optional secretKey parameter aligns with the PR's objective of migrating from websocket to console domain.

agent/main/lib/FrameOutOfProcess.ts (1)

28-28: LGTM! Consistent implementation across components

The change maintains consistency with the Page class implementation, ensuring uniform network management across both in-process and out-of-process frames.

agent/main/test/mitm.test.ts (1)

40-42: LGTM! Filter added for internal traffic.

The addition of the heroInternalUrl filter aligns well with the PR's objective of handling internal traffic differently after migrating from websocket to console domain.

agent/main/lib/BrowserContext.ts (3)

43-43: LGTM! Interface updated with secretKey.

The addition of the optional secretKey to IBrowserContextCreateOptions is well-typed and maintains interface consistency.


79-79: LGTM! BrowserContext properly handles secretKey.

The secretKey property is correctly declared and initialized from options, following the class's existing patterns.

Also applies to: 99-99


117-117: LGTM! Simplified proxy bypass configuration.

The proxy bypass list has been appropriately simplified after removing websocket functionality, now only including loopback addresses.

agent/main/lib/NetworkManager.ts (3)

65-65: LGTM! Constructor updated with secretKey parameter.

The secretKey parameter is properly added to the constructor and declared as a public property.


630-630: LGTM! Simplified WebSocket handling.

The WebSocket creation handler has been appropriately simplified as part of the migration away from WebSocket-based communication.


308-311: Verify the security implications of exposing secretKey in URLs.

While the implementation is functional, including the secretKey in URLs might have security implications:

  1. The key could be logged in server logs
  2. It might be visible in browser history
  3. It could be exposed through referrer headers

Consider these alternatives:

  1. Use a custom header instead of URL parameters
  2. Use a more secure authentication mechanism

Run this script to check for potential security implications:

agent/main/lib/Console.ts Outdated Show resolved Hide resolved
agent/main/lib/Console.ts Outdated Show resolved Hide resolved
agent/main/lib/Agent.ts Outdated Show resolved Hide resolved
agent/mitm/handlers/RequestSession.ts Outdated Show resolved Hide resolved
agent/main/lib/Page.ts Show resolved Hide resolved
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: 2

♻️ Duplicate comments (2)
agent/main/lib/Console.ts (2)

125-125: ⚠️ Potential issue

Do not log secretKey to the console to prevent exposure

Including secretKey in console output can lead to security vulnerabilities if logs are exposed. Remove secretKey from the console.debug statement to protect sensitive information.

Apply this diff:

- console.debug(`${this.secretKey}, ${clientId}, ${serializedData}`);
+ console.debug(`${clientId}, ${serializedData}`);

Update the handleConsoleMessage method to parse messages without secretKey.


65-67: ⚠️ Potential issue

Ensure safe string interpolation to prevent injection vulnerabilities

Directly interpolating variables into stringified code can introduce security risks. Ensure this.secretKey and script are sanitized before embedding.

Validate or sanitize this.secretKey and script to prevent injection attacks.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ba740cd and e6091e7.

📒 Files selected for processing (2)
  • agent/main/lib/Agent.ts (3 hunks)
  • agent/main/lib/Console.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • agent/main/lib/Agent.ts
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: Test chrome-115-0 (node 20.x; ubuntu-latest)
  • GitHub Check: Test chrome-120-0 (node 20.x; ubuntu-latest)
  • GitHub Check: Test chrome-130-0 (node 20.x; ubuntu-latest)
  • GitHub Check: Test chrome-latest (node 20; ubuntu-latest)
  • GitHub Check: Test chrome-115-0 (node 20.x; ubuntu-latest)
  • GitHub Check: Test chrome-latest (node 18; ubuntu-latest)
  • GitHub Check: Test chrome-120-0 (node 20.x; ubuntu-latest)
  • GitHub Check: Test chrome-130-0 (node 20.x; ubuntu-latest)
  • GitHub Check: Test chrome-latest (node 22; ubuntu-latest)
  • GitHub Check: Test chrome-latest (node 20; ubuntu-latest)
  • GitHub Check: Test chrome-latest (node 18; ubuntu-latest)
  • GitHub Check: Test chrome-latest (node 20; macos-13)
  • GitHub Check: Test chrome-latest (node 22; windows-latest)
  • GitHub Check: Test chrome-latest (node 18; macos-13)
  • GitHub Check: Test chrome-latest (node 20; windows-latest)
  • GitHub Check: Test chrome-latest (node 18; windows-latest)
  • GitHub Check: Test chrome-latest (node 22; macos-13)
  • GitHub Check: Test chrome-latest (node 20; macos-13)
  • GitHub Check: Build Javascript
  • GitHub Check: Test chrome-latest (node 18; macos-13)

agent/main/lib/Console.ts Outdated Show resolved Hide resolved
agent/main/lib/Console.ts Outdated Show resolved Hide resolved
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

♻️ Duplicate comments (1)
agent/main/lib/Console.ts (1)

41-45: ⚠️ Potential issue

Security: Avoid exposing secretKey in URL parameters

The secretKey should not be included in URL parameters as it can be exposed in logs and referrer headers.

🧹 Nitpick comments (2)
agent/main/lib/Console.ts (2)

15-17: Update comment to reflect console-based communication

The comment still references websocket messaging which is outdated since this implementation uses console-based communication.

-  // We store resolvable when we received websocket message before, receiving
-  // targetId, this way we can await this, and still trigger to get proper ids.
+  // We store resolvable when we received console message before receiving
+  // targetId, allowing us to await and resolve with proper ids when available.

1-130: Consider alternative approaches to secure communication

While using the console for communication is creative, it introduces several security concerns and complexity. Consider these architectural alternatives:

  1. Use a dedicated internal protocol handler (e.g., hero://) for secure communication
  2. Implement a proper message port or broadcast channel
  3. Use service workers for secure message passing

Would you like me to elaborate on any of these alternative approaches?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e6091e7 and 56d621b.

📒 Files selected for processing (1)
  • agent/main/lib/Console.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (19)
  • GitHub Check: Test chrome-115-0 (node 20.x; ubuntu-latest)
  • GitHub Check: Test chrome-120-0 (node 20.x; ubuntu-latest)
  • GitHub Check: Test chrome-130-0 (node 20.x; ubuntu-latest)
  • GitHub Check: Test chrome-latest (node 18; ubuntu-latest)
  • GitHub Check: Test chrome-115-0 (node 20.x; ubuntu-latest)
  • GitHub Check: Test chrome-120-0 (node 20.x; ubuntu-latest)
  • GitHub Check: Test chrome-130-0 (node 20.x; ubuntu-latest)
  • GitHub Check: Test chrome-latest (node 20; macos-13)
  • GitHub Check: Test chrome-latest (node 22; ubuntu-latest)
  • GitHub Check: Test chrome-latest (node 20; ubuntu-latest)
  • GitHub Check: Test chrome-latest (node 18; macos-13)
  • GitHub Check: Test chrome-latest (node 18; ubuntu-latest)
  • GitHub Check: Test chrome-latest (node 22; windows-latest)
  • GitHub Check: Test chrome-latest (node 20; windows-latest)
  • GitHub Check: Test chrome-latest (node 18; windows-latest)
  • GitHub Check: Test chrome-latest (node 22; macos-13)
  • GitHub Check: Test chrome-latest (node 20; macos-13)
  • GitHub Check: Build Javascript
  • GitHub Check: Test chrome-latest (node 18; macos-13)
🔇 Additional comments (2)
agent/main/lib/Console.ts (2)

26-39: LGTM! Solid initialization implementation

The initialization logic properly handles the ready state and sets up console event subscription.


47-57: LGTM! Clean frame registration implementation

The frame registration logic properly handles both immediate and deferred resolution of frameIds.

agent/main/lib/Console.ts Show resolved Hide resolved
agent/main/lib/Console.ts Outdated Show resolved Hide resolved
agent/main/lib/Console.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@blakebyrnes blakebyrnes left a comment

Choose a reason for hiding this comment

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

Looks great! A few changes/things I'd like to verify

  1. Can we ensure the requests are not making it through in both mitm AND when mitm is disabled? Does request session apply to both, or should we add by default to the list of blocked urls we send to chrome or something?

  2. Can you verify that these requests don't get stored in the session database? That caused a LOT of extra content that we didn't need last time.

@soundofspace
Copy link
Contributor Author

  1. Can we ensure the requests are not making it through in both mitm AND when mitm is disabled? Does request session apply to both, or should we add by default to the list of blocked urls we send to chrome or something?

By using fetch domain and custom url we can make sure it never leaves localhost

  1. Can you verify that these requests don't get stored in the session database? That caused a LOT of extra content that we didn't need last time.

Nothing is stored in resources on network level but devtoolsMessages does contain Console.messageAdded entries now with all the callback data, we probably want to filter this?

@soundofspace soundofspace force-pushed the migrate-from-websocket-to-deprecated-console-domain branch from c77ed1e to 3a2ceca Compare January 20, 2025 12:46
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