Skip to content

fix-rollbar (4783/465148540610): guard against null PopStateEvent.state in rep max calculator#616

Open
astashovai wants to merge 1 commit into
astashov:masterfrom
astashovai:fix/rollbar-465148540610
Open

fix-rollbar (4783/465148540610): guard against null PopStateEvent.state in rep max calculator#616
astashovai wants to merge 1 commit into
astashov:masterfrom
astashovai:fix/rollbar-465148540610

Conversation

@astashovai

Copy link
Copy Markdown
Contributor

Summary

  • Add optional chaining (?.) when accessing e.state.reps in the popstate event handler in RepMaxContent
  • PopStateEvent.state can be null when navigating to a history entry created by normal navigation (not pushState/replaceState), causing a TypeError

Rollbar

https://app.rollbar.com/a/astashov/fix/item/liftosaur/4783/occurrence/465148540610

Decision

Fixed because this is a legitimate bug in our code on a public-facing page (rep max calculator). The error affects normal user flows — users hitting browser back/forward can trigger this crash.

Root Cause

The popstate event handler in RepMaxContent accesses e.state.reps without guarding against e.state being null. The PopStateEvent.state property is null for history entries not created via pushState/replaceState (e.g., the initial page load entry). When a user navigates back to such an entry, the handler crashes with TypeError: null is not an object (evaluating 'e.state.reps').

Test plan

  • Navigate to any rep max calculator page (e.g. /ten-rep-max-calculator)
  • Use browser back/forward buttons — should not crash
  • Change reps input and verify URL updates correctly
  • Use back button to navigate between rep max states — reps should restore from history state

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.

1 participant