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

Redirection when spawner is pending #1534

DerekHeldtWerle opened this Issue Nov 13, 2017 · 1 comment


None yet
2 participants

DerekHeldtWerle commented Nov 13, 2017

Currently in jupyterhub when a user is pending a spawn and clicks the home button it will redirect
the user to /hub/home since the user is not running:

def get(self):
        user = self.get_current_user()
        if user.running:
            # trigger poll_and_notify event in case of a server that died
            yield user.spawner.poll_and_notify()
        # send the user to /spawn if they aren't running,
        # to establish that this is an explicit spawn request rather
        # than an implicit one, which can be caused by any link to `/user/:name`
        url = user.url if user.running else url_path_join(self.hub.base_url, 'spawn')
        html = self.render_template('home.html',

This brings up the option for the user to "Start my server" again. When not using any options form the user will be redirected back to /user/:name if they click the "Start my server" button. However, when using an options form and the "Start my server" button is clicked, it will always redirect the user back to the options form as long as the user is pending:

        user = self.get_current_user()
        if not self.allow_named_servers and user.running:
            url = user.url
            self.log.debug("User is running: %s", url)
        if user.spawner.options_form: 
            # Explicit spawn request: clear _spawn_future
            # which may have been saved to prevent implicit spawns
            # after a failure.
            if user.spawner._spawn_future and user.spawner._spawn_future.done():
                user.spawner._spawn_future = None
            # not running, no form. Trigger spawn by redirecting to /user/:name

From here the user will consequently receive an error 400 for every request to start a server.

    def post(self):
        """POST spawns with user-specified options"""
        user = self.get_current_user()
        if not self.allow_named_servers and user.running:
            url = user.url
            self.log.warning("User is already running: %s", url)
        if user.spawner.pending:
            raise web.HTTPError(
                400, "%s is pending %s" % (user.spawner._log_name, user.spawner.pending)

I propose that if the spawner is pending, instead of having the user even be presented with the option to "Start my server" always redirect them to /hub/user/:name when the home button is clicked and the spawner is pending. This not only solves the bug of when a options form is used and the user is unable to get to their notebook without explicitly changing the url, but also in terms of usability, it stops the user from undergoing the experience of being able to repeatedly click "Start my server" for the duration of the spawner pending. See my PR for the minor changes needed to get this functionality. #1533


This comment has been minimized.

DerekHeldtWerle commented Nov 21, 2017

Fixed and merged into #1533

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment