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

fix: do not always error out api calls when web socket initially failed #1495

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion packages/client/src/coordinator/connection/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,15 @@ export class StreamClient {
await Promise.all([
this.tokenManager.tokenReady(),
this.guestUserCreatePromise,
this.connectionIdPromise,
]);
try {
await this.connectionIdPromise;
Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, do we even need connectionIdPromise? Can we just always do waitForHealthy instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

good point here, I think we dont need it too, I ll remove it

Copy link
Member Author

Choose a reason for hiding this comment

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

@myandrienko not really for anonymous users we have this code inside the client

    // some endpoints require a connection_id to be resolved.
    // as anonymous users aren't allowed to open WS connections, we just
    // resolve the connection_id here.
    this.resolveConnectionId?.();

so need to keep this

} catch (e) {
// in case connection id was rejected
// reconnection maybe in progress
// we can wait for healthy connection to resolve, which rejects when 15s timeout is reached
await this.wsConnection?._waitForHealthy();
}
}
const requestConfig = this._enrichAxiosOptions(options);
try {
Expand Down
Loading