You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
PR Review: Scope form sessions to form_id to avoid conflicts
Summary
This PR fixes a critical bug where form sessions were being shared across different forms, causing them to "clobber" each other. The fix scopes the session cookie to include the formId, changing from form_session_id to form_session_id_${formId}.
✅ Strengths
Critical bug fix: Correctly identifies and fixes a session collision issue
Minimal, focused change: Only 3 lines changed, reducing risk
Consistent implementation: All three cookie operations (get, set, delete) are updated consistently
⚠️ Issues Found
1. Critical: Breaking change in localStorage (apps/spotlight)
The client-side code in apps/spotlight still uses the old non-scoped session key:
Impact: This creates a mismatch between server-side cookies (now scoped) and client-side localStorage (still global), which will cause session persistence to break across page reloads when users work with multiple forms.
There's no automated test that validates users can work with multiple forms simultaneously without session interference.
Recommendation: Add an E2E test that:
Opens form A and fills some fields
Opens form B in a new tab/context and fills fields
Returns to form A and verifies the session data is intact
Returns to form B and verifies its session data is intact
This would have caught this bug earlier and prevent regressions.
4. Potential Cookie Storage Concerns
Question: What happens to orphaned cookies when forms are deleted? Each form now creates its own cookie, which could accumulate over time.
Recommendation: Consider implementing:
Cookie cleanup on form completion/deletion
Max-age/expiration policies for form session cookies
Documentation of cookie lifecycle
5. Security: Cookie Name Predictability
The cookie name includes the formId directly, which is somewhat predictable. While not necessarily a vulnerability, consider whether this exposes any information.
Low priority, but worth considering if formId values should be less predictable or if cookie attributes (httpOnly, secure, sameSite) need review.
📋 Action Items
Must fix before merge:
Update apps/spotlight/src/features/form-page/store/actions/initialize.ts:12 to use scoped localStorage key
Update apps/spotlight/src/features/form-page/store/actions/on-submit-form.ts:40 to use scoped localStorage key
Update test at packages/server/src/pages/forms/[id].test.ts:238 to use new cookie format
Do not merge until the localStorage mismatch is fixed. The core fix is correct and important, but the incomplete migration will cause session persistence bugs in the spotlight app.
Once the localStorage references are updated and tests pass, this will be a solid bug fix. Great catch on the session collision issue!
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
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.
No description provided.