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

Websocket shutdown logic #2277

Open
wants to merge 8 commits into
base: IronGauntlets/implement-subscribeEvents
Choose a base branch
from

Conversation

kirugan
Copy link
Contributor

@kirugan kirugan commented Nov 20, 2024

No description provided.

@IronGauntlets IronGauntlets force-pushed the IronGauntlets/implement-subscribeEvents branch 2 times, most recently from 5a713f0 to bf93293 Compare November 20, 2024 11:52
Copy link
Contributor

@pnowosie pnowosie left a comment

Choose a reason for hiding this comment

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

👍 Just small concerns

case <-ctx.Done():
// in case websocket connection is closed and server is not in shutdown mode
// we need to release this goroutine from waiting
}
Copy link
Contributor

Choose a reason for hiding this comment

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

World you mind to add return here to make it more clear we intend to exit the goroutine?
For me it'd more readable 🤔

@@ -20,7 +20,7 @@ func testConnection(t *testing.T, ctx context.Context, method jsonrpc.Method, li
require.NoError(t, rpc.RegisterMethods(method))

// Server
srv := httptest.NewServer(jsonrpc.NewWebsocket(rpc, utils.NewNopZapLogger()))
srv := httptest.NewServer(jsonrpc.NewWebsocket(rpc, nil, utils.NewNopZapLogger()))
Copy link
Contributor

Choose a reason for hiding this comment

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

According to this article nil channel will block indefinitely, which is I think counter-intuitive.
Maybe it's worth to add a comment that it will block?

@@ -347,7 +347,7 @@ func TestMultipleSubscribeNewHeadsAndUnsubscribe(t *testing.T) {
Params: []jsonrpc.Parameter{{Name: "id"}},
Handler: handler.Unsubscribe,
}))
ws := jsonrpc.NewWebsocket(server, log)
ws := jsonrpc.NewWebsocket(server, nil, log)
Copy link
Contributor

Choose a reason for hiding this comment

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

Also comment about the nil-channel behaviour? (see prev comment)

@IronGauntlets IronGauntlets force-pushed the IronGauntlets/implement-subscribeEvents branch 9 times, most recently from c218d68 to 301962d Compare November 26, 2024 12:47
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.

3 participants