fix(frontend): guard chart tooltip canvas lifecycle#1927
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a non-exported helper that checks whether a Chart's canvas (or its context's canvas) is connected, switches chart-update eligibility to use that helper, and adds early-return guards in two plugin draw hooks; tests added to assert no drawing occurs when Changes
Sequence Diagram(s)(No sequence diagrams generated — changes are small, localized guards and tests.) Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/chart-plugins.unit.test.ts (1)
48-48: Useit.concurrentfor these two independent unit tests.Line [48] and Line [75] can run in parallel and should use
it.concurrent(...)to align with test-suite conventions.♻️ Suggested patch
- it('skips drawing the vertical hover line when the canvas is disconnected', () => { + it.concurrent('skips drawing the vertical hover line when the canvas is disconnected', () => { @@ - it('skips drawing the today line when the canvas is disconnected', () => { + it.concurrent('skips drawing the today line when the canvas is disconnected', () => {As per coding guidelines,
tests/**/*.{ts,js}: Useit.concurrent()instead ofit()when possible to run tests in parallel within the same file, maximizing parallelism for faster CI/CD.Also applies to: 75-75
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/chart-plugins.unit.test.ts` at line 48, Two independent test cases should run in parallel: replace the two `it(...)` blocks with `it.concurrent(...)` for the test titled "skips drawing the vertical hover line when the canvas is disconnected" and the other `it` at the reported location (line ~75) so both tests use `it.concurrent(...)`; locate the `it` calls by their test titles in tests/chart-plugins.unit.test.ts and change their callers from `it` to `it.concurrent` (no other logic changes).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/chart-plugins.unit.test.ts`:
- Line 48: Two independent test cases should run in parallel: replace the two
`it(...)` blocks with `it.concurrent(...)` for the test titled "skips drawing
the vertical hover line when the canvas is disconnected" and the other `it` at
the reported location (line ~75) so both tests use `it.concurrent(...)`; locate
the `it` calls by their test titles in tests/chart-plugins.unit.test.ts and
change their callers from `it` to `it.concurrent` (no other logic changes).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5d05fac2-e69c-4c15-9c11-04e7c1ede7e4
📒 Files selected for processing (2)
src/services/chartTooltip.tstests/chart-plugins.unit.test.ts
|



Summary (AI generated)
Motivation (AI generated)
PostHog reported a
TypeError: Cannot read properties of null (reading 'save')from the chart tooltip bundle. Our custom Chart.js plugins were still attempting to draw after the canvas lifecycle had already ended, which can happen during teardown or navigation.Business Impact (AI generated)
This removes a chart crash from statistics screens, especially around fast navigation or mobile teardown paths, which keeps analytics views stable and reduces noisy client-side errors in PostHog.
Test Plan (AI generated)
bunx vitest run tests/chart-plugins.unit.test.tsbunx eslint src/services/chartTooltip.ts tests/chart-plugins.unit.test.tsbun typecheckGenerated with AI
Summary by CodeRabbit
Bug Fixes
Tests