refactor: Switch from localStorage to sessionStorage and clean up on navigation#5
Open
thejuggernaut01 wants to merge 2 commits intoJC-Coder:mainfrom
Open
refactor: Switch from localStorage to sessionStorage and clean up on navigation#5thejuggernaut01 wants to merge 2 commits intoJC-Coder:mainfrom
thejuggernaut01 wants to merge 2 commits intoJC-Coder:mainfrom
Conversation
…nfigurations and implement cleanup on component unmount.
There was a problem hiding this comment.
Pull request overview
This PR updates the client-side migration flow to store migration configuration and draft connection strings in sessionStorage (instead of localStorage) and adds cleanup on route transitions to reduce persistence of sensitive data.
Changes:
- Switch migration config persistence (
migration_${jobId}) fromlocalStoragetosessionStoragefor start + retry flows. - Add navigation/unmount cleanup to remove
db_mover_draft_${dbType}(Config page) and both draft + migration config (Migration page).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| client/src/pages/ConfigPage.tsx | Writes migration config to sessionStorage and removes draft data on unmount/navigation. |
| client/src/pages/MigrationPage.tsx | Reads/writes retry config via sessionStorage and removes draft + migration config on unmount/navigation. |
Comments suppressed due to low confidence (1)
client/src/pages/ConfigPage.tsx:44
- sessionStorage.setItem() can throw (quota exceeded / storage blocked). Because this is inside the same try as the API call, a storage write failure would route into the catch path and report “Migration failed” even though the migration job may already have been started successfully. Consider guarding the storage write with its own try/catch and treating failures as a non-fatal loss of retry capability (e.g. log + toast warning, but still navigate).
// Store migration config for retry functionality
sessionStorage.setItem(
`migration_${jobId}`,
JSON.stringify({
type: "copy",
sourceUri: config.sourceUri,
targetUri: config.targetUri,
dbType: dbType,
}),
);
💡 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.
Problem
Migration configurations (
migration_${jobId}) were stored inlocalStorage, meaning they persisted across browser sessions indefinitely — even after the tab or browser was closed. This is unnecessary since migration configs are only needed during the active session. Additionally, draft connection strings (db_mover_draft_${dbType}) and migration configs were never cleaned up when users navigated away from the page, leaving stale sensitive data in storage.Changes
client/src/pages/ConfigPage.tsx
localStorage.setItem→sessionStorage.setItemfor storing migration configs (migration_${jobId}), so data is automatically cleared when the tab is closed.useEffectcleanup that removesdb_mover_draft_${dbType}from session storage when the user navigates away from the config page. This handles the case where a user enters connection strings (triggering draft auto-save) but navigates elsewhere without starting a migration or manually clearing the draft.client/src/pages/MigrationPage.tsx
localStorage.getItem/localStorage.setItem→sessionStoragefor reading and storing migration configs during retry.useEffectcleanup function. When a user navigates away from the migration page:dbTypefrom the storedmigration_${jobId}configdb_mover_draft_${dbType}keymigration_${jobId}key itselfWhy sessionStorage over localStorage
useEffectcleanups handle the remaining case where data persists during in-app navigation within the same tab.