Skip to content

chore: add cherry-picks #15898 and #15927 to backport the fix to #15616 #16265

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

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion coderd/healthcheck/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"time"

"golang.org/x/xerrors"
"nhooyr.io/websocket"

"github.com/coder/coder/v2/coderd/healthcheck/health"
"github.com/coder/coder/v2/codersdk/healthsdk"
"github.com/coder/websocket"
)

type WebsocketReport healthsdk.WebsocketReport
Expand Down
2 changes: 1 addition & 1 deletion coderd/httpapi/httpapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ const websocketCloseMaxLen = 123
func WebsocketCloseSprintf(format string, vars ...any) string {
msg := fmt.Sprintf(format, vars...)

// Cap msg length at 123 bytes. nhooyr/websocket only allows close messages
// Cap msg length at 123 bytes. coder/websocket only allows close messages
// of this length.
if len(msg) > websocketCloseMaxLen {
// Trim the string to 123 bytes. If we accidentally cut in the middle of
Expand Down
2 changes: 1 addition & 1 deletion coderd/httpapi/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"time"

"golang.org/x/xerrors"
"nhooyr.io/websocket"

"cdr.dev/slog"
"github.com/coder/websocket"
)

// Heartbeat loops to ping a WebSocket to keep it alive.
Expand Down
5 changes: 2 additions & 3 deletions coderd/provisionerjobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ import (

"github.com/google/uuid"
"golang.org/x/xerrors"
"nhooyr.io/websocket"

"cdr.dev/slog"
"github.com/coder/coder/v2/codersdk/wsjson"

"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/db2sdk"
"github.com/coder/coder/v2/coderd/database/dbauthz"
"github.com/coder/coder/v2/coderd/database/pubsub"
"github.com/coder/coder/v2/coderd/httpapi"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/wsjson"
"github.com/coder/coder/v2/provisionersdk"
"github.com/coder/websocket"
)

// Returns provisioner logs based on query parameters.
Expand Down
2 changes: 1 addition & 1 deletion coderd/provisionerjobs_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
"nhooyr.io/websocket"

"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/dbmock"
Expand All @@ -23,6 +22,7 @@ import (
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/provisionersdk"
"github.com/coder/coder/v2/testutil"
"github.com/coder/websocket"
)

func TestConvertProvisionerJob_Unit(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions coderd/workspaceagents.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"golang.org/x/exp/slices"
"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"
"nhooyr.io/websocket"
"tailscale.com/tailcfg"

"cdr.dev/slog"
Expand All @@ -42,6 +41,7 @@ import (
"github.com/coder/coder/v2/codersdk/wsjson"
"github.com/coder/coder/v2/tailnet"
"github.com/coder/coder/v2/tailnet/proto"
"github.com/coder/websocket"
)

// @Summary Get workspace agent by ID
Expand Down Expand Up @@ -378,7 +378,7 @@ func (api *API) workspaceAgentLogs(rw http.ResponseWriter, r *http.Request) {

// Allow client to request no compression. This is useful for buggy
// clients or if there's a client/server incompatibility. This is
// needed with e.g. nhooyr/websocket and Safari (confirmed in 16.5).
// needed with e.g. coder/websocket and Safari (confirmed in 16.5).
//
// See:
// * https://github.com/nhooyr/websocket/issues/218
Expand Down
2 changes: 1 addition & 1 deletion coderd/workspaceagents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/stretchr/testify/require"
"golang.org/x/xerrors"
"google.golang.org/protobuf/types/known/timestamppb"
"nhooyr.io/websocket"
"tailscale.com/tailcfg"

"cdr.dev/slog"
Expand Down Expand Up @@ -50,6 +49,7 @@ import (
"github.com/coder/coder/v2/tailnet/tailnettest"
"github.com/coder/coder/v2/testutil"
"github.com/coder/quartz"
"github.com/coder/websocket"
)

func TestWorkspaceAgent(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion coderd/workspaceagentsrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/google/uuid"
"github.com/hashicorp/yamux"
"golang.org/x/xerrors"
"nhooyr.io/websocket"

"cdr.dev/slog"
"github.com/coder/coder/v2/agent/proto"
Expand All @@ -30,6 +29,7 @@ import (
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/tailnet"
tailnetproto "github.com/coder/coder/v2/tailnet/proto"
"github.com/coder/websocket"
)

// @Summary Workspace agent RPC API
Expand Down
7 changes: 3 additions & 4 deletions coderd/workspaceagentsrpc_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@ import (
"testing"
"time"

"github.com/coder/coder/v2/coderd/util/ptr"
"github.com/coder/coder/v2/coderd/wspubsub"

"github.com/google/uuid"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
"nhooyr.io/websocket"

"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/dbmock"
"github.com/coder/coder/v2/coderd/database/dbtime"
"github.com/coder/coder/v2/coderd/util/ptr"
"github.com/coder/coder/v2/coderd/wspubsub"
"github.com/coder/coder/v2/testutil"
"github.com/coder/websocket"
)

func TestAgentConnectionMonitor_ContextCancel(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion coderd/workspaceapps/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/go-jose/go-jose/v4/jwt"
"github.com/google/uuid"
"go.opentelemetry.io/otel/trace"
"nhooyr.io/websocket"

"cdr.dev/slog"
"github.com/coder/coder/v2/agent/agentssh"
Expand All @@ -32,6 +31,7 @@ import (
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/workspacesdk"
"github.com/coder/coder/v2/site"
"github.com/coder/websocket"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion codersdk/agentsdk/agentsdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/google/uuid"
"github.com/hashicorp/yamux"
"golang.org/x/xerrors"
"nhooyr.io/websocket"
"storj.io/drpc"
"tailscale.com/tailcfg"

Expand All @@ -25,6 +24,7 @@ import (
"github.com/coder/coder/v2/codersdk"
drpcsdk "github.com/coder/coder/v2/codersdk/drpc"
tailnetproto "github.com/coder/coder/v2/tailnet/proto"
"github.com/coder/websocket"
)

// ExternalLogSourceID is the statically-defined ID of a log-source that
Expand Down
2 changes: 1 addition & 1 deletion codersdk/provisionerdaemons.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import (
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"
"nhooyr.io/websocket"

"github.com/coder/coder/v2/buildinfo"
"github.com/coder/coder/v2/codersdk/drpc"
"github.com/coder/coder/v2/codersdk/wsjson"
"github.com/coder/coder/v2/provisionerd/proto"
"github.com/coder/coder/v2/provisionerd/runner"
"github.com/coder/websocket"
)

type LogSource string
Expand Down
2 changes: 1 addition & 1 deletion codersdk/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"net"

"nhooyr.io/websocket"
"github.com/coder/websocket"
)

// wsNetConn wraps net.Conn created by websocket.NetConn(). Cancel func
Expand Down
2 changes: 1 addition & 1 deletion codersdk/websocket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"nhooyr.io/websocket"

"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/testutil"
"github.com/coder/websocket"
)

// TestWebsocketNetConn_LargeWrites tests that we can write large amounts of data thru the netconn
Expand Down
2 changes: 1 addition & 1 deletion codersdk/workspaceagents.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (

"github.com/google/uuid"
"golang.org/x/xerrors"
"nhooyr.io/websocket"

"github.com/coder/coder/v2/coderd/tracing"
"github.com/coder/coder/v2/codersdk/wsjson"
"github.com/coder/websocket"
)

type WorkspaceAgentStatus string
Expand Down
2 changes: 1 addition & 1 deletion codersdk/workspacesdk/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
"slices"

"golang.org/x/xerrors"
"nhooyr.io/websocket"

"cdr.dev/slog"
"github.com/coder/coder/v2/buildinfo"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/tailnet"
"github.com/coder/coder/v2/tailnet/proto"
"github.com/coder/websocket"
)

var permanentErrorStatuses = []int{
Expand Down
2 changes: 1 addition & 1 deletion codersdk/workspacesdk/dialer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
"nhooyr.io/websocket"
"tailscale.com/tailcfg"

"cdr.dev/slog"
Expand All @@ -26,6 +25,7 @@ import (
tailnetproto "github.com/coder/coder/v2/tailnet/proto"
"github.com/coder/coder/v2/tailnet/tailnettest"
"github.com/coder/coder/v2/testutil"
"github.com/coder/websocket"
)

func TestWebsocketDialer_TokenController(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion codersdk/workspacesdk/workspacesdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

"github.com/google/uuid"
"golang.org/x/xerrors"
"nhooyr.io/websocket"
"tailscale.com/tailcfg"
"tailscale.com/wgengine/capture"

Expand All @@ -23,6 +22,7 @@ import (
"github.com/coder/coder/v2/tailnet"
"github.com/coder/coder/v2/tailnet/proto"
"github.com/coder/quartz"
"github.com/coder/websocket"
)

var ErrSkipClose = xerrors.New("skip tailnet close")
Expand Down
3 changes: 1 addition & 2 deletions codersdk/wsjson/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import (
"encoding/json"
"sync/atomic"

"nhooyr.io/websocket"

"cdr.dev/slog"
"github.com/coder/websocket"
)

type Decoder[T any] struct {
Expand Down
3 changes: 2 additions & 1 deletion codersdk/wsjson/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import (
"encoding/json"

"golang.org/x/xerrors"
"nhooyr.io/websocket"

"github.com/coder/websocket"
)

type Encoder[T any] struct {
Expand Down
3 changes: 1 addition & 2 deletions enterprise/coderd/provisionerdaemons.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ import (
"go.opentelemetry.io/otel/trace"
"golang.org/x/exp/maps"
"golang.org/x/xerrors"
"nhooyr.io/websocket"
"storj.io/drpc/drpcmux"
"storj.io/drpc/drpcserver"

"cdr.dev/slog"

"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/db2sdk"
"github.com/coder/coder/v2/coderd/database/dbauthz"
Expand All @@ -35,6 +33,7 @@ import (
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/provisionerd/proto"
"github.com/coder/coder/v2/provisionersdk"
"github.com/coder/websocket"
)

func (api *API) provisionerDaemonsEnabledMW(next http.Handler) http.Handler {
Expand Down
2 changes: 1 addition & 1 deletion enterprise/coderd/workspaceproxycoordinate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"net/http"

"github.com/google/uuid"
"nhooyr.io/websocket"

"github.com/coder/coder/v2/apiversion"
"github.com/coder/coder/v2/coderd/httpapi"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/tailnet/proto"
"github.com/coder/websocket"
)

// @Summary Workspace Proxy Coordinate
Expand Down
2 changes: 1 addition & 1 deletion enterprise/wsproxy/wsproxysdk/wsproxysdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/google/uuid"
"golang.org/x/xerrors"
"nhooyr.io/websocket"
"tailscale.com/tailcfg"

"cdr.dev/slog"
Expand All @@ -19,6 +18,7 @@ import (
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/workspacesdk"
agpl "github.com/coder/coder/v2/tailnet"
"github.com/coder/websocket"
)

// Client is a HTTP client for a subset of Coder API routes that external
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ replace github.com/dlclark/regexp2 => github.com/dlclark/regexp2 v1.7.0

// There are a few minor changes we make to Tailscale that we're slowly upstreaming. Compare here:
// https://github.com/tailscale/tailscale/compare/main...coder:tailscale:main
replace tailscale.com => github.com/coder/tailscale v1.1.1-0.20241003034647-02286e537fc2
replace tailscale.com => github.com/coder/tailscale v1.1.1-0.20241218201526-b53d914d625f

// This is replaced to include
// 1. a fix for a data race: c.f. https://github.com/tailscale/wireguard-go/pull/25
Expand Down Expand Up @@ -177,7 +177,7 @@ require (
golang.org/x/crypto v0.31.0
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa
golang.org/x/mod v0.22.0
golang.org/x/net v0.31.0
golang.org/x/net v0.32.0
golang.org/x/oauth2 v0.24.0
golang.org/x/sync v0.10.0
golang.org/x/sys v0.28.0
Expand All @@ -192,7 +192,6 @@ require (
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gopkg.in/yaml.v3 v3.0.1
gvisor.dev/gvisor v0.0.0-20240509041132-65b30f7869dc
nhooyr.io/websocket v1.8.7
storj.io/drpc v0.0.33
tailscale.com v1.46.1
)
Expand All @@ -205,6 +204,7 @@ require (
github.com/charmbracelet/bubbletea v1.2.1
github.com/charmbracelet/lipgloss v1.0.0
github.com/coder/serpent v0.10.0
github.com/coder/websocket v1.8.12
github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21
github.com/emersion/go-smtp v0.21.2
github.com/go-jose/go-jose/v4 v4.0.2
Expand Down
Loading
Loading