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

Connection status handling #1150

Merged
merged 1 commit into from Oct 21, 2020
Merged

Connection status handling #1150

merged 1 commit into from Oct 21, 2020

Conversation

mason-fish
Copy link
Contributor

fixes #1099

Changes

  • Introduce connection statuses, stored in the clusters state.
  • Persist spaces state.
  • Initialization no longer depends on zqd and instead the data syncs come from the loaded app components

Every time the app loads we reset all statuses to "initial", indicating that we are unsure if the connection will succeed yet, and also indicating that we need to sync with server data. While syncing, if the connection fails we set the status to "disconnected" and display as much in a new tab content page where the user my attempt to retry.

brim

Signed-off-by: Mason Fish mason@looky.cloud

Copy link
Member

@jameskerr jameskerr left a comment

Choose a reason for hiding this comment

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

Right on! I like the code. I'm glad we talked and thought about it for a minute. Thanks for deleting all that old login stuff too.

In addition to the suggestions below, here are a few thoughts.

Yellow Notice

Now that we have this connection error view, the yellow notice that says "Failed to fetch" is unnecessary. I think it should not appear in this case (when we're testing out a connection).

Screen Shot 2020-10-15 at 10 41 01 AM

This might be more difficult than it seems. We pop up that "Notice" if any request in the whole app throws. You'll have to see if there is a way to remove the error handler only here, or if we need to remove it from where it is now and place it only where it's needed.

Wording of notice

As Al suggested, I think the wording of this error message needs to be updated to:

The service at {host}:{port} could not be reached.

Screen Shot 2020-10-15 at 10 40 52 AM

flex-direction: column;
`

const StyledHeader = styled.h1`
Copy link
Member

Choose a reason for hiding this comment

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

This text style is called "heading/page" in sketch. Will you add it to the styled components theme then include it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure thing

margin: 110px 0 0 0;
font-size: 24px;
font-weight: 700;
color: ${(p) => p.theme.colors.aqua};
Copy link
Member

Choose a reason for hiding this comment

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

Any objection to using color: var(--aqua) ?

const onClick = async () => {
setIsFetching(true)
await retry()
console.log("done")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
console.log("done")

Comment on lines 25 to 26
font-size: 13px;
font-weight: 400;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
font-size: 13px;
font-weight: 400;
${(p) => p.theme.typography.labelNormal}


const onClick = async () => {
setIsFetching(true)
await retry()
Copy link
Member

Choose a reason for hiding this comment

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

It might sound backward, but would you add a slight delay before actually retrying. Just long enough so that we're guaranteed to see the spinner. This will make it feel more responsive. If the spinner never appears, the user will wonder... did I click it?

I suggest here 300ms but play with value to see what feels good.

Suggested change
await retry()
await new Promise((r) => setTimeout(r, 300)
await retry()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah interesting! I had put in a wait just to test that it worked properly but then took it back out. I noticed the missing feedback then and that's why I added the Notice to the retry method, but if we end up removing that then I def agree that some sort of feedback is important

@@ -13,13 +13,15 @@ export const setConnection = (cluster: Cluster) => (
return zealot
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this file needs to be renamed to initConnection, similar to how we have initSpace and initTab


const setupConnection = (host, port) => (dispatch, _, {globalDispatch}) => {
const cluster = {
console.log("setup connection running")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
console.log("setup connection running")

}
dispatch(Clusters.add(cluster))
globalDispatch(Clusters.add(cluster))
dispatch(Current.setConnectionId(cluster.id))
}

export default async function(store: Store) {
const {space, host, port, id} = getUrlSearchParams()
export default function(store: Store) {
Copy link
Member

Choose a reason for hiding this comment

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

+1 to simpler code here

import Viewer from "../Viewer"
import {getZealot} from "../../flows/getZealot"

export function connectCluster(cluster: Cluster): Thunk<Promise<void>> {
Copy link
Member

Choose a reason for hiding this comment

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

❤️ that this all is gone

}

export type Status = "initial" | "connected" | "disconnected"
Copy link
Member

Choose a reason for hiding this comment

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

Might be better to call this ConnectionStatus since we have other places we use the word Status. (SearchStatus, ViewerStatus, ChartStatus, UidStatus...etc)

@mason-fish mason-fish force-pushed the 1099-sync_zqd_post_init branch 5 times, most recently from 21897c4 to 7ce03e3 Compare October 19, 2020 21:14
@mason-fish mason-fish mentioned this pull request Oct 19, 2020
@mason-fish mason-fish force-pushed the 1099-sync_zqd_post_init branch 6 times, most recently from 0a8afc2 to 1a81b6c Compare October 20, 2020 19:22
Copy link
Member

@jameskerr jameskerr left a comment

Choose a reason for hiding this comment

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

Looks awesome. I like the delay, works very well.

dispatch(setConnection(c)).catch((e) => {
dispatch(Notice.set(e))
dispatch(initConnection(c)).catch(() => {
dispatch(Current.setConnectionId(c.id))
Copy link
Member

Choose a reason for hiding this comment

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

Oh nice! Easy

Signed-off-by: Mason Fish <mason@looky.cloud>
@mason-fish mason-fish merged commit 8636e29 into master Oct 21, 2020
@mason-fish mason-fish deleted the 1099-sync_zqd_post_init branch October 21, 2020 17:43
@philrz philrz linked an issue Oct 21, 2020 that may be closed by this pull request
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.

Blank screen failure caused by inaccessible remote zqd Crash when no current space and network error
2 participants