discord-api-docs icon indicating copy to clipboard operation
discord-api-docs copied to clipboard

[RPC] Events are delayed when connecting more than 2 times

Open Hacksore opened this issue 1 year ago • 1 comments

Description

I seem to have uncovered either a neat bug or feature that I'm trying to understand why it exists.

tl;dr my app connecting to the RPC websocket after more than two attempts will result in an extended delay for getting events back on stable.

This doesn't seem to happen for your app streamkit at all on stable. Furthermore, on canary this does not happen to my app and every connection is free of any delay in receiving events.

This really messes with auth flow for my app, if users have tried to load the app more than twice and it's cause a confusing UX and they perceive it as not being able to sign in.

I know I'm going to be told that I should be using IPC instead of WebSocket but this is also reproducible on the IPC transport.

IPC repro: https://github.com/Hacksore/test-rpc-djs/blob/test-ready/index.js

Steps to Reproduce

Using my test setup.

  1. Open discord
  2. Load https://overlayed.dev/test (source code)
  3. Refresh (it loads ready)
  4. Refresh (it loads ready)
  5. It is stuck waiting for the READY event

alternatively use the IPC repro I gave above and run the script a few times.

Expected Behavior

Should allow me to connect without delay in responses.

Current Behavior

Delay in getting events back after 2 connection attempts.

Screenshots/Videos

https://github.com/user-attachments/assets/0c979627-66db-43f8-9ea4-f3c4b0f6dd5d

Client and System Information

Desktop client: stable 333428 (3995449) Host 0.0.321 arm64 Build Override: N/A macOS 15 (24.0.0)

Hacksore avatar Oct 07 '24 13:10 Hacksore

As for the delay it will connect instantly to the socket and dispatch READY approximately ~20 seconds later. image

Hacksore avatar Oct 07 '24 13:10 Hacksore

I'm confused why this issue is still open, but I can confirm that this behavior is working as intended. There's a socket throttler on new connections, so if the same application is opening multiple connections to the client we intentionally slow down their connections. To avoid this, keep open and utilize a single connection.

night avatar Apr 01 '25 02:04 night