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

Catch ValueError while waiting for server to be reachable #4733

Merged
merged 4 commits into from
Mar 19, 2024

Conversation

kreuzert
Copy link
Contributor

@kreuzert kreuzert commented Mar 18, 2024

closes #4732

This is the patch we've added to our JupyterHub setup, to avoid the failed start attempts described in the issue.

@@ -295,6 +295,8 @@ async def is_reachable():
errno.ECONNRESET,
}:
app_log.warning("Failed to connect to %s (%s)", url, e)
except ValueError as e:
Copy link
Member

Choose a reason for hiding this comment

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

We keep expanding this, I wonder if this should be except Exception as e. That would swallow some errors inappropriately, e.g. NameError: url if there was a typo there, but I think the vast majority of errors to be raised here are likely to be like the one you just encountered. And the failure mode of catching too many here is only a delay in reporting real errors, rather than the current situation which is inappropriate failure that can't be worked around.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If one can trust the Spawner.poll function, errors and non-running notebook-servers should be catched anyway, shouldn't they?
IMHO we can change it to except Exception as e.

I can update the PR if you like

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, go for it. I think that makes the most sense.

@minrk minrk added the bug label Mar 18, 2024
errno.ECONNREFUSED,
errno.ECONNRESET,
}:
app_log.warning("Failed to connect to %s (%s)", url, e)
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I wasn't clear what except Exception should replace. This OSError block should stay. We still want to avoid logging the expected "not there yet" errors, but log and not fail on unexpected errors.

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 sure. Sorry for that. Should be fine now.

@minrk
Copy link
Member

minrk commented Mar 19, 2024

Thanks!

@minrk minrk merged commit 1db5e5e into jupyterhub:main Mar 19, 2024
16 of 18 checks passed
@minrk
Copy link
Member

minrk commented Mar 19, 2024

@meeseeksdev please backport to 4.x

meeseeksmachine pushed a commit to meeseeksmachine/jupyterhub that referenced this pull request Mar 19, 2024
minrk added a commit that referenced this pull request Mar 19, 2024
…3-on-4.x

Backport PR #4733 on branch 4.x (Catch ValueError while waiting for server to be reachable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"ValueError: IOStream is not idle; cannot convert to SSL" while waiting for http server
2 participants