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(connect): defer token creation after iframe open #2812

Merged
merged 2 commits into from
Oct 3, 2024

Conversation

bodinsamuel
Copy link
Collaborator

Describe your changes

  • Defer token creation after iframe open
    Allow to pass the token after the iframe is created so we can display a loading screen instead of just nothing

@bodinsamuel bodinsamuel self-assigned this Oct 3, 2024
Copy link
Collaborator

@TBonnin TBonnin left a comment

Choose a reason for hiding this comment

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

one question about the timeout duration but lgtm otherwise

return;
}
connectUI.current!.setSessionToken(res.json.data.token);
}, 10);
Copy link
Collaborator

Choose a reason for hiding this comment

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

that's a pretty short value. no? what happen if the call to connect/sessions takes longer than that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The call is triggered after 10ms.

The setTimeout is just here to free the main event loop, which means the iframe can be created and the URL loading started, the iframe doesn't have a separate sandbox so it's important that it has time to load and display something.
Then the setTimeout triggers and it takes as much time as it needs.
10ms is not a lot but on a good connection waiting for nothing would be detrimental to UX.

@bodinsamuel bodinsamuel enabled auto-merge (squash) October 3, 2024 15:24
@bodinsamuel bodinsamuel merged commit 195e526 into master Oct 3, 2024
21 checks passed
@bodinsamuel bodinsamuel deleted the sam/fix/connect-ui-defer-loading branch October 3, 2024 15:32
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.

2 participants