Skip to content

chore: fix nuked nhooyr/websocket dependency #1

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maxim-inj
Copy link

@maxim-inj maxim-inj commented May 6, 2025

Summary by CodeRabbit

  • Chores
    • Updated dependencies to use a new websocket implementation.
    • Reorganized and updated Go module dependencies for improved management.

Copy link

coderabbitai bot commented May 6, 2025

Walkthrough

The changes update the Go module version and migrate the WebSocket dependency from nhooyr.io/websocket to github.com/coder/websocket throughout the codebase. The dependency list is reorganized to clarify direct and indirect dependencies, and unused dependencies are removed. No logic or public API changes are introduced.

Changes

File(s) Change Summary
go.mod Updated Go version to 1.23, replaced nhooyr.io/websocket with github.com/coder/websocket, reorganized and cleaned up dependencies.
go/grpcweb/options.go
go/grpcweb/websocket_wrapper.go
go/grpcweb/wrapper.go
go/grpcwebproxy/main.go
Changed WebSocket import from nhooyr.io/websocket to github.com/coder/websocket. No logic changes.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant grpcwebproxy
    participant websocket (github.com/coder/websocket)
    participant Backend

    Client->>grpcwebproxy: Initiate WebSocket connection
    grpcwebproxy->>websocket (github.com/coder/websocket): Handle WebSocket handshake and communication
    grpcwebproxy->>Backend: Forward gRPC request
    Backend-->>grpcwebproxy: Respond with gRPC data
    grpcwebproxy->>websocket (github.com/coder/websocket): Send data over WebSocket
    grpcwebproxy-->>Client: Return response via WebSocket
Loading

Poem

In the warren where the code does hop,
We swapped our webs for a coder's shop.
Old dependencies swept away,
New ones here, more neat today.
Go version climbs, the modules dance—
With every change, we bunnies prance!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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

Support

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

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​improbable-eng/​grpc-web@​0.13.01001009879100
Addednpm/​google-protobuf@​3.14.010010010083100
Addedgolang/​github.com/​coder/​websocket@​v1.8.1388100100100100

View full report

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

🧹 Nitpick comments (1)
go/grpcweb/websocket_wrapper.go (1)

15-15: Validate websocket wrapper functionality remains intact.
After migrating to "github.com/coder/websocket", ensure that critical methods used by webSocketResponseWriter and webSocketWrappedReader (Write, Read, Ping, SetReadLimit, Close, etc.) behave identically to the previous implementation. Consider adding or updating unit/integration tests for websocket flows.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1d9bbb0 and 15b50bb.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (5)
  • go.mod (2 hunks)
  • go/grpcweb/options.go (1 hunks)
  • go/grpcweb/websocket_wrapper.go (1 hunks)
  • go/grpcweb/wrapper.go (1 hunks)
  • go/grpcwebproxy/main.go (1 hunks)
🔇 Additional comments (4)
go/grpcweb/wrapper.go (1)

14-14:

❓ Verification inconclusive

Verify websocket API compatibility.
The import of "github.com/coder/websocket" replaces nhooyr.io/websocket. Please confirm that the new module exports all required functions and types (e.g., Accept, AcceptOptions, MessageBinary, Conn.SetReadLimit, Conn.Ping) used in HandleGrpcWebsocketRequest and related code.

Run:


🏁 Script executed:

rg -R "AcceptOptions" -n $(go env GOPATH)/pkg/mod/github.com/coder/[email protected]
rg -R "func Accept" -n $(go env GOPATH)/pkg/mod/github.com/coder/[email protected]

Length of output: 1015


🏁 Script executed:

#!/bin/bash
# Verify that github.com/coder/[email protected] exports the needed symbols
MODDIR="$(go env GOPATH)/pkg/mod/github.com/coder/[email protected]"
rg "AcceptOptions" -n "$MODDIR"
rg -e "func Accept" -n "$MODDIR"
rg "MessageBinary" -n "$MODDIR"
rg "SetReadLimit" -n "$MODDIR"
rg "Ping" -n "$MODDIR"

Length of output: 999


🏁 Script executed:

#!/bin/bash
# Determine the exact version of github.com/coder/websocket in use
rg "github.com/coder/websocket" -n go.mod go.sum

Length of output: 286


🏁 Script executed:

#!/bin/bash
# Locate the module directory via go list and verify exported symbols
MODDIR=$(go list -m -json github.com/coder/[email protected] | awk -F '"' '/"Dir":/ {print $4}')
echo "Module directory: $MODDIR"
rg "AcceptOptions" -n "$MODDIR"
rg -e "func Accept" -n "$MODDIR"
rg "MessageBinary" -n "$MODDIR"
rg "SetReadLimit" -n "$MODDIR"
rg "Ping" -n "$MODDIR"

Length of output: 470


Manual Verification Required: Confirm websocket API Compatibility
Unable to locate the downloaded github.com/coder/[email protected] source in this environment for automated inspection. Please ensure that the new module provides the same exports used in your code:

  • Accept(ctx, w, r, opts…) / AcceptOptions
  • MessageBinary
  • Conn.SetReadLimit
  • Conn.Ping

These are referenced in go/grpcweb/wrapper.go’s HandleGrpcWebsocketRequest.

go/grpcweb/options.go (1)

10-10: Dependency update approved.
The import of "github.com/coder/websocket" aligns with the updated go.mod and matches usage of websocket.CompressionMode. No issues found.

go.mod (2)

3-3: Verify Go version bump compatibility.
The go directive has been updated to 1.23. Ensure that all CI pipelines and contributor environments support this version. Update documentation (e.g., README) to reflect the new minimum Go version if necessary.


7-7: Confirm new websocket dependency version.
The require block now includes github.com/coder/websocket v1.8.13. Please verify that this version is correct, trusted, and free of known vulnerabilities. Consider running go mod tidy, go mod verify, and checking relevant advisory databases.

@@ -10,7 +10,7 @@ import (
"sync"
"time"

"nhooyr.io/websocket"
"github.com/coder/websocket"
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Ensure import grouping and remove old websocket import.
The new import "github.com/coder/websocket" is correctly added but it's currently splitting standard library imports (e.g., it sits before "crypto/tls"). Consider moving it to the external dependencies block (after all stdlib imports) to abide by import grouping conventions. Also verify that all occurrences of the old "nhooyr.io/websocket" import have been removed across the codebase.

Run:


🏁 Script executed:

rg -n "nhooyr.io/websocket"

Length of output: 205


🏁 Script executed:

#!/bin/bash
sed -n '1,50p' go/grpcwebproxy/main.go

Length of output: 2599


Import grouping: move github.com/coder/websocket into the external imports block

Verified that there are no remaining code references to nhooyr.io/websocket (only a mention in CHANGELOG.md). Please adjust the import order so that all stdlib imports—including "crypto/tls"—are grouped together, followed by third-party imports:

go/grpcwebproxy/main.go:

 import (
     "fmt"
     "log"
     "net"
     "net/http"
     _ "net/http/pprof" // register in DefaultServerMux
     "os"
     "sync"
     "time"

-    "github.com/coder/websocket"
     "crypto/tls"
+    "github.com/coder/websocket"

     grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
     grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"
     grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
     …
 )
📝 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
"github.com/coder/websocket"
import (
"fmt"
"log"
"net"
"net/http"
_ "net/http/pprof" // register in DefaultServerMux
"os"
"sync"
"time"
"crypto/tls"
"github.com/coder/websocket"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
)

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