fix(analytics-browser): cookie re-entrancy problem in isEnabled#1539
Merged
daniel-graham-amplitude merged 1 commit intoFeb 17, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a re-entrancy bug in the CookieStorage.isEnabled() method where concurrent calls from multiple instances could interfere with each other due to a shared static variable. The fix changes testValue from a static class variable to a local variable within the method.
Changes:
- Removed static
testValuevariable and made it local toisEnabled()method to prevent concurrent calls from different instances from interfering with each other - Added regression test to verify concurrent calls to
isEnabled()work correctly - Added manual test HTML file to verify the fix in a browser environment
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/analytics-core/src/storage/cookie.ts | Changed testValue from static class variable to local variable in isEnabled() method |
| packages/analytics-core/test/storage/cookies.test.ts | Added regression test for re-entrancy issue with concurrent isEnabled() calls |
| test-server/cookies/is-enabled.html | Added manual browser test for verifying parallel and sequential isEnabled() calls |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Change "CookieStorage" isEnabled function to set "testValue" as a local variable instead of a static variable, which can cause re-entrancy issues.
Checklist
Note
Low Risk
Small, isolated change to cookie availability probing plus added tests; low risk aside from subtle behavior differences under concurrent calls.
Overview
Fixes a re-entrancy/race issue in
CookieStorage.isEnabled()by removing the shared statictestValueand using a per-call local value when writing/reading the temporary probe cookie.Adds a Jest regression test that runs
isEnabled()concurrently across instances, and includes a simpletest-serverHTML page to manually verify parallel and sequentialisEnabled()calls stay consistentlytrue.Written by Cursor Bugbot for commit 4a661c4. This will update automatically on new commits. Configure here.