-
Notifications
You must be signed in to change notification settings - Fork 17
Joao/fix reconnection after verto invite only #1227
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 9519fc2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Does this PR need to target the base branch or the main branch? |
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.
I would look into the flow of not attaching any workers before receiving the verto.invite response. It might help us reducing all these complexities.
However, since this is urgent, I would suggest fixing the CI problems so that we can merge the PR.
Please look into my double retry logic comment for the verto invite.
video = true | ||
negotiateVideo = true | ||
} | ||
const queryParams = new URLSearchParams(query) |
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.
Please run the prettier
this.logger.error('Invite error', error) | ||
reject(error) | ||
} | ||
return asyncRetry({ |
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.
I don't think the retry logic should be touching the internal methods/or API calls. This will make the SDK inconsistent, and it also does not care about developer-passed params, which means the developer can not control the retry specifically for the verto.invite
.
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.
Also, I am confused. The global retry will also retry this API? Because this will in the end call the verto.invite
, which will trigger the execute
, and execute
has a global retry logic. So, is this API nested under two retry methods?
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.
The global retry doesn't retry verto.invites
anymore, let it be handled here...
The verto.invite
is a special case, and this is the main reason users are being disconnected from calls ATM.
In a nutshell, the SDK can't replay a verto.invite
, it's to "execute" a new one using a new RTCPeer, or just after connecting, the call will disconnect for various reasons.
We may find other RPC with the same characteristics, but this PR only focuses on the verto.invite
request.
return asyncRetry({ | ||
asyncCallable: async () => { | ||
return new Promise(async (resolve, reject) => { | ||
await this._waitUntilSessionAuthorized() |
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.
How do you think the user can call this API if the session is not authorized? This is already a part of the connect logic. If that does not happen, the user can't call this API. If that happens, then do we need to wait here?
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.
It's not the user calling it, but he next scheduled retry, which is normally faster than the authentication.
So this Retry usage/implementation needs to handle that, or it's going to fail again.
@@ -794,7 +844,7 @@ export class BaseConnection< | |||
} | |||
|
|||
/** @internal */ | |||
onLocalSDPReady(rtcPeer: RTCPeer<EventTypes>) { | |||
async onLocalSDPReady(rtcPeer: RTCPeer<EventTypes>) { |
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 is not an async method
async onLocalSDPReady(rtcPeer: RTCPeer<EventTypes>) { | |
onLocalSDPReady(rtcPeer: RTCPeer<EventTypes>) { |
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.
async
is not required here, but the method returns Promises, and since the return is being inferred,
Having the async
act as a reminder for us, reading the code the the method is an async execution.
this.logger.debug('Invite response', response) | ||
|
||
this.resuming = false | ||
} catch (error) { | ||
this.setState('hangup') | ||
this.setState('hangup') |
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.
run prettier please
|
||
getLogger().debug('promoteDemoteWorker:', action.type, action.payload) | ||
getLogger().debug('promoteDemoteWorker:', action.type, action.payload) |
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.
Run the prettier, please. I don't understand the changes here.
if (this.state === 'requesting') { | ||
// The Server Created the call, and now is trying to connect us to the destination | ||
this.setState('trying') | ||
} |
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.
What's the point? Where are you using this trying
state? The SDK is already setting the state to requesting
when the invite begins, and it only sets the state to active
when verto.answer
is received. Please check the vertoEventWorker
code.
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.
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.
trying
is a well-known state in a call setup.
https://github.com/signalwire/signalwire-js/blob/main/packages/core/src/utils/interfaces.ts#L276
The SDK should be in the requesting
state only until the request is confirmed by the server.
After the successful request, the state should now be trying
and later after the verto.answer
active.
This makes more sense in 1:1 calls, supported by the CF SDK. I believe that's why it was missing in the Video SDK.
changing the base on this one too |
Description
This is a slip from #1216 to simplify the revision

This is handle case 2
Type of change
Code snippets
In case of new feature or breaking changes, please include code snippets.