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

fix(webapp): fixes crash when hitting back button #1419

Merged
merged 1 commit into from
Aug 18, 2022
Merged

Conversation

eh-am
Copy link
Collaborator

@eh-am eh-am commented Aug 17, 2022

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 and until parameters), while in redux only a single action is dispatched at a time:
Screen Shot 2022-08-17 at 16 37 44

Which leads to a somewhat inconsistent state, where we are mixing relative values (like from) with absolute values (unix timestamp)
Screen Shot 2022-08-17 at 16 37 27

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:
Screen Shot 2022-08-17 at 16 44 47

However since it happens so fast, we end up cancelling the previous request.

@github-actions
Copy link
Contributor

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
webapp/public/assets/app.js 417.13 KB (+0.01% 🔺) 8.4 s (+0.01% 🔺) 3.6 s (-16.09% 🔽) 11.9 s
webapp/public/assets/app.css 14.99 KB (0%) 300 ms (0%) 0 ms (+100% 🔺) 300 ms
webapp/public/assets/styles.css 9.39 KB (0%) 188 ms (0%) 0 ms (+100% 🔺) 188 ms
packages/pyroscope-flamegraph/dist/index.js 90.77 KB (0%) 1.9 s (0%) 2.2 s (+1.1% 🔺) 4 s
packages/pyroscope-flamegraph/dist/index.node.js 90.64 KB (0%) 1.9 s (0%) 910 ms (+52.82% 🔺) 2.8 s
packages/pyroscope-flamegraph/dist/index.css 6.94 KB (0%) 139 ms (0%) 0 ms (+100% 🔺) 139 ms

@codecov
Copy link

codecov bot commented Aug 17, 2022

Codecov Report

Merging #1419 (46e3145) into main (e2128b9) will increase coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1419      +/-   ##
==========================================
+ Coverage   68.34%   68.37%   +0.03%     
==========================================
  Files         129      129              
  Lines        4248     4252       +4     
  Branches     1153     1155       +2     
==========================================
+ Hits         2903     2907       +4     
  Misses       1340     1340              
  Partials        5        5              
Impacted Files Coverage Δ
webapp/javascript/util/formatDate.ts 92.99% <100.00%> (+0.53%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@eh-am eh-am marked this pull request as ready for review August 17, 2022 19:54
@Rperry2174
Copy link
Contributor

/create-server

Copy link
Contributor

@Rperry2174 Rperry2174 left a comment

Choose a reason for hiding this comment

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

lgtm 🔥 !

@eh-am eh-am merged commit 6f69c6f into main Aug 18, 2022
@eh-am eh-am deleted the fix/webapp-history branch August 18, 2022 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants