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

JS: Remove dead state transition validation code #1771

Merged
merged 1 commit into from
Oct 9, 2023

Commits on Oct 9, 2023

  1. JS: Remove dead state transition validation code

    Soooo, because `this.state` was initialised to `null` and
    not 'start', this code was always actually dead.
    `validateStateTransition` had no branch for `oldState` being
    null, so always returned `false`. This meant `this.state`
    was *never* set to current state, and so in all callbacks,
    `oldState` was always `null`!
    
    I validated this again by console.logging `oldState` and
    `newState` inside `validateStateTransition`. Here's the output
    for when a full build is performed:
    
    ```
    null -> waiting
    null -> fetching
    null -> unknown
    null -> building
    null -> failed
    null -> built
    null -> launching
    ```
    
    And for when launching a previously built image
    ```
    null -> launching
    null -> ready
    ```
    
    I also put one just above where `this.state` is set, and that
    code was never called.
    
    I was hoping to remove all this code anyway, as it doesn't
    actually validate nor test anything - that's really done by
    unit tests and integration tests. I thought this would hide
    bugs - but turns out, it was a bug itself, and hid nothing.
    
    This also changes the signature of the callback for
    `onChangeState`, dropping `oldState` and `newState`. `oldState`
    was always `null`, and in our code, we actually don't use
    `newState` *at all*. The one place that was conditional on
    `oldState` being null is now unconditional, because `oldState`
    was always `null`.
    
    Ref jupyterhub#774
    yuvipanda committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    e2985f7 View commit details
    Browse the repository at this point in the history