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:
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 newStateat all. The one place that was conditional on oldState being null is now unconditional, because oldState was always null.
Soooo, because
this.state
was initialised tonull
and not 'start', this code was always actually dead.validateStateTransition
had no branch foroldState
being null, so always returnedfalse
. This meantthis.state
was never set to current state, and so in all callbacks,oldState
was alwaysnull
!I validated this again by console.logging
oldState
andnewState
insidevalidateStateTransition
. Here's the output for when a full build is performed:And for when launching a previously built image
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
, droppingoldState
andnewState
.oldState
was alwaysnull
, and in our code, we actually don't usenewState
at all. The one place that was conditional onoldState
being null is now unconditional, becauseoldState
was alwaysnull
.Ref https://github.com/jupyterhub/binderhub/issues/774