fix: replace ws library with native WebSocket for CDP reliability - #29
Open
Parithosh-Varma wants to merge 1 commit into
Open
Parithosh-Varma wants to merge 1 commit into
Parithosh-Varma wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The bundled
wsWebSocket library causesUnexpected server response: 101errors when tools likebrowser_navigate,browser_click, andbrowser_filltry to connect to Chrome's CDP endpoint. This happens because thewslibrary bundled viabun builddoesn't handle the WebSocket handshake correctly in all runtimes.Fix
wsimport with the nativeWebSocketAPI (available in Node 21+ and Bun)readyStatechecks to use numeric constants instead ofWebSocket.OPENTesting
Verified locally that
browser_list,browser_navigate,browser_snapshot,browser_click,browser_fill,browser_eval, andbrowser_screenshotall work with Chrome started via:/Applications/Google Chrome.app/Contents/MacOS/Google Chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug --disable-gpu --no-first-run &