-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat: fetch gateway information without requiring rest in ws #10651
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10651 +/- ##
==========================================
- Coverage 38.00% 37.29% -0.71%
==========================================
Files 239 239
Lines 14884 15164 +280
Branches 1385 1386 +1
==========================================
- Hits 5657 5656 -1
- Misses 9216 9496 +280
- Partials 11 12 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Just one classic mistake I've made a few times too, callbacks aren't encodeable over worker_threads, so this needs updating, otherwise we get hard crashes:
export interface FetchingStrategyOptions | |
extends Omit< | |
WebSocketManagerOptions, | |
| 'buildIdentifyThrottler' | |
| 'buildStrategy' | |
| 'rest' | |
| 'retrieveSessionInfo' | |
| 'shardCount' | |
| 'shardIds' | |
| 'updateSessionInfo' | |
> { | |
readonly gatewayInformation: APIGatewayBotInfo; | |
readonly shardCount: number; | |
} |
Along with its runtime counter-part:
export async function managerToFetchingStrategyOptions(manager: WebSocketManager): Promise<FetchingStrategyOptions> { | |
const { | |
buildIdentifyThrottler, | |
buildStrategy, | |
retrieveSessionInfo, | |
updateSessionInfo, | |
shardCount, | |
shardIds, | |
rest, | |
...managerOptions | |
} = manager.options; | |
return { | |
...managerOptions, | |
token: manager.token, | |
gatewayInformation: await manager.fetchGatewayInformation(), | |
shardCount: await manager.getShardCount(), | |
}; | |
} |
In the future I'll probably rewrite this to a Pick 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems the README and tests need updating
this needs a rebase now |
89c2b68
to
2626c9a
Compare
Please describe the changes this PR makes and why it should be merged:
Currently the only way to override the gateway URL that
/ws
will connect to is by intercepting the rest request and overriding it. This PR lets you pick a different ws url, if you may be proxying it or have custom implementations or what not.Status and versioning classification: