Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sfc-gh-tteixeira
Copy link
Contributor

@sfc-gh-tteixeira sfc-gh-tteixeira commented May 14, 2025

Describe your changes

Today, when the Streamlit frontend is unable to connect to the server we eventually show an error dialog (after plenty of retries). But there are two issues:

  1. The messaging in the error dialog is a bit cryptic.

    → This PR makes the message nicer to the user

  2. While the error dialog is visible, we continue retrying to connect to the server. But if we're suddenly successful at establishing a connection to the sever, the "disconnected" dialog stays open.

    → This PR closes that dialog when reconnected.

PS: This PR also reduces the min and max time we use in our connection retry logic.

GitHub Issue Link (if applicable)

n/a

Testing Plan

  • Explanation of why no additional tests are needed
  • ✅ Unit Tests (JS and/or Python)
  • E2E Tests
  • Any manual testing needed?

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@snyk-io
Copy link
Contributor

snyk-io bot commented May 14, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@github-actions
Copy link
Contributor

github-actions bot commented May 14, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-11366/streamlit-1.45.1-py3-none-any.whl
🕹️ Preview app pr-11366.streamlit.app (☁️ Deploy here if not accessible)

switch (dialogProps.type) {
case DialogType.ABOUT:
return aboutDialog(dialogProps)
return <AboutDialog {...dialogProps} />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just using proper Reacty syntax here.

showConnectionError(title: string, errorMarkdown: string): void {
LOG.error(errorMarkdown)
const newDialog: DialogProps = {
type: DialogType.CONNECTION_ERROR,
Copy link
Contributor Author

@sfc-gh-tteixeira sfc-gh-tteixeira May 14, 2025

Choose a reason for hiding this comment

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

Previously, connection errors used the WARNING dialog type, but for this work I needed to know whether there was a connection error dialog open (not just any warning dialog) in order to rescind it. So I added a new type of dialog called CONNECTION_ERROR, and duplicated some of the word that handled the warning dialog.

// to inform the host of connection error
const shouldSendClientError =
totalTries === THRESHOLD_FOR_CONNECTION_ERROR_DIALOG
const tooManyRetries = totalTries >= MAX_RETRIES_BEFORE_CLIENT_ERROR
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just some nicer variable names.

export const PING_MINIMUM_RETRY_PERIOD_MS = 500
export const PING_MAXIMUM_RETRY_PERIOD_MS = 1000 * 60
export const PING_MINIMUM_RETRY_PERIOD_MS = 100
export const PING_MAXIMUM_RETRY_PERIOD_MS = 2000
Copy link
Contributor Author

@sfc-gh-tteixeira sfc-gh-tteixeira May 14, 2025

Choose a reason for hiding this comment

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

I reduced these so retries happen faster. No need to wait 60s before retrying to connect -- at that point the user just refreshes the page anyway. So let's make this 2s, max.

@sfc-gh-tteixeira sfc-gh-tteixeira marked this pull request as ready for review May 14, 2025 23:25
@mayagbarnes mayagbarnes added security-assessment-completed Security assessment has been completed for PR change:refactor PR contains code refactoring without behavior change impact:users PR changes affect end users labels May 15, 2025
Copy link
Collaborator

@mayagbarnes mayagbarnes left a comment

Choose a reason for hiding this comment

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

Was just manual testing ✅
Just couple lint things in the JS test run

@sfc-gh-tteixeira sfc-gh-tteixeira merged commit 0d7ddb3 into develop May 15, 2025
38 checks passed
@sfc-gh-tteixeira sfc-gh-tteixeira deleted the connection-errors branch May 15, 2025 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:refactor PR contains code refactoring without behavior change impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants