fix(webapp): fixes crash when hitting back button #1419
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Original issue:
When selecting a time range and hitting the back button
https://user-images.githubusercontent.com/6951209/185229101-47444c01-7644-460e-b194-404750e681c8.mp4
This happens due to
redux-sync
, which syncs the URL with the redux state both ways.The url changes all at once (both
from
anduntil
parameters), while in redux only a single action is dispatched at a time:Which leads to a somewhat inconsistent state, where we are mixing relative values (like
from
) with absolute values (unixtimestamp
)Which then generates a wrong date, crashing
date-fns
(https://github.com/pyroscope-io/pyroscope/blob/e2128b9e7fdde0fc823985c098b1b86ddcf710f9/webapp/javascript/util/formatDate.ts#L56-L58)So my lazy solution is to just check whether it's a valid date, and if not, to just return an empty string. Since this is used as a label only, it should be somewhat fine.
Ahh how I would love using
Maybe
here :)BTW the problem also happens when loading data:
However since it happens so fast, we end up cancelling the previous request.