Skip to content

fix(web): prevent memory leak in onboarding interval cleanup#5671

Open
hobostay wants to merge 1 commit into
Helicone:mainfrom
hobostay:fix/onboarding-interval-memory-leak
Open

fix(web): prevent memory leak in onboarding interval cleanup#5671
hobostay wants to merge 1 commit into
Helicone:mainfrom
hobostay:fix/onboarding-interval-memory-leak

Conversation

@hobostay

Copy link
Copy Markdown

Summary

  • Fix memory leak in OnboardingProvider where startOnboarding creates a setInterval that is never cleaned up
  • The original code returned a cleanup function from startOnboarding, but since it is called as a regular callback (not from useEffect), the cleanup was never invoked
  • Store the interval ID in a ref and clean it up on unmount, when starting a new check, and when the onboarding condition is met

Before: If the request count never exceeded 6 (onboarding never triggered), the polling interval would run indefinitely until the page was closed.

After: The interval is properly tracked and cleaned up in all cases.

Test plan

  • Trigger onboarding flow - verify it still works correctly when request count exceeds 6
  • Navigate away from the page before onboarding triggers - verify the interval is cleaned up (check for network requests stopping)
  • Call startOnboarding multiple times - verify no duplicate intervals are created

Generated with Claude Code (https://claude.com/claude-code)

The `startOnboarding` callback created a `setInterval` and returned a
cleanup function, but the cleanup was never invoked because it was called
as a regular function (not from useEffect). If onboarding was never
triggered (request count never exceeded 6), the interval would run forever.

Store the interval in a ref and clean it up:
- On component unmount via useEffect cleanup
- When starting a new onboarding check (avoid duplicate intervals)
- When the onboarding condition is met

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel

vercel Bot commented May 10, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Helicone Team on Vercel.

A member of the Team first needs to authorize it.

@vercel vercel Bot temporarily deployed to Preview – helicone-bifrost May 10, 2026 10:29 Inactive

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@vercel

vercel Bot commented May 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
helicone-bifrost Skipped Skipped May 10, 2026 10:29am

Request Review

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