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: infinite loop when combining controls #1569

Merged
merged 3 commits into from
Nov 28, 2024
Merged

Conversation

pauldambra
Copy link
Member

see https://posthoghelp.zendesk.com/agent/tickets/21246

When waiting for a linked flag to activate recordings, and also pausing on URL, the browser could get stuck in a loop trying to emit a custom event that it had paused when it had not yet started,

so the note it emitted triggered the pause check which again tried to pause

which caused a custom event

etc

Copy link

vercel bot commented Nov 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
posthog-js ✅ Ready (Inspect) Visit Preview Nov 28, 2024 1:29pm

@pauldambra pauldambra added the bump patch Bump patch version when this PR gets merged label Nov 28, 2024
@pauldambra pauldambra requested a review from a team November 28, 2024 12:37
Comment on lines +395 to +397
if (this._urlBlocked) {
return 'paused'
}
Copy link
Member Author

@pauldambra pauldambra Nov 28, 2024

Choose a reason for hiding this comment

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

the fix is to have this as the (almost) earliest check in status
rrweb continues to emit, because it doesn't know that it is paused
and we continue to check
until the URL changes and we resume

@@ -501,13 +501,15 @@ export class SessionRecording {
if (isNullish(this._removePageViewCaptureHook)) {
// :TRICKY: rrweb does not capture navigation within SPA-s, so hook into our $pageview events to get access to all events.
// Dropping the initial event is fine (it's always captured by rrweb).
this._removePageViewCaptureHook = this.instance._addCaptureHook((eventName) => {
this._removePageViewCaptureHook = this.instance.on('eventCaptured', (event) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

changed this to not rely on a semi private method

Comment on lines 509 to 512
const href = event?.properties.$current_url
? this._maskUrl(event?.properties.$current_url)
: ''
if (!href || this.status !== 'active') {
Copy link
Member Author

Choose a reason for hiding this comment

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

pageview already tells you what URL it is, so we don't need to ask the window

Copy link
Member Author

Choose a reason for hiding this comment

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

fly by change that had been annoying me

Copy link

github-actions bot commented Nov 28, 2024

Size Change: +662 B (+0.02%)

Total Size: 3.18 MB

Filename Size Change
dist/array.full.es5.js 257 kB +67 B (+0.03%)
dist/array.full.js 361 kB +65 B (+0.02%)
dist/array.full.no-external.js 360 kB +65 B (+0.02%)
dist/array.js 175 kB +67 B (+0.04%)
dist/array.no-external.js 174 kB +67 B (+0.04%)
dist/main.js 175 kB +67 B (+0.04%)
dist/module.full.js 361 kB +65 B (+0.02%)
dist/module.full.no-external.js 360 kB +65 B (+0.02%)
dist/module.js 175 kB +67 B (+0.04%)
dist/module.no-external.js 174 kB +67 B (+0.04%)
ℹ️ View Unchanged
Filename Size
dist/all-external-dependencies.js 206 kB
dist/customizations.full.js 12.2 kB
dist/dead-clicks-autocapture.js 14.3 kB
dist/exception-autocapture.js 9.37 kB
dist/external-scripts-loader.js 2.29 kB
dist/recorder-v2.js 115 kB
dist/recorder.js 115 kB
dist/surveys-preview.js 57.6 kB
dist/surveys.js 63.2 kB
dist/tracing-headers.js 1.75 kB
dist/web-vitals.js 10.3 kB

compressed-size-action

@pauldambra pauldambra merged commit 001405f into main Nov 28, 2024
13 checks passed
@pauldambra pauldambra deleted the fix/infinite-loop branch November 28, 2024 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump patch Bump patch version when this PR gets merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants