Clear Corrupted Queue Script
Quick utility to clear corrupted sync queue and reset local storage
Clear Corrupted Queue Script
🎯 Purpose
This script clears corrupted sync queue data and resets your local storage to start fresh with backend synchronization.
🚀 Quick Fix - Run in Console
Option 1: Clear Everything (Recommended for Fresh Start)
Open your browser's DevTools Console (F12) and run:
// Clear corrupted IndexedDB
const databases = await indexedDB.databases();
for (const db of databases) {
console.log(`Deleting database: ${db.name}`);
await indexedDB.deleteDatabase(db.name);
}
// Clear localStorage
localStorage.clear();
// Clear sessionStorage
sessionStorage.clear();
console.log('✅ All local data cleared!');
console.log('🔄 Reloading page...');
// Reload page to start fresh
setTimeout(() => location.reload(), 1000);
Option 2: Clear Only Sync Queue (Preserve Local Data)
// Open IndexedDB connection
const dbRequest = indexedDB.open('gograb-space-storage');
dbRequest.onsuccess = async function(event) {
const db = event.target.result;
try {
// Clear sync queue
const transaction = db.transaction(['storage'], 'readwrite');
const store = transaction.objectStore('storage');
// Delete sync queue key
await store.delete('core-angular:sync:queue');
console.log('✅ Sync queue cleared!');
console.log('🔄 Reloading page...');
setTimeout(() => location.reload(), 1000);
} catch (error) {
console.error('Failed to clear sync queue:', error);
}
};
dbRequest.onerror = function() {
console.error('Failed to open database');
};
Option 3: Clear Only Spaces (Start with Fresh Backend Data)
// Open IndexedDB connection
const dbRequest = indexedDB.open('gograb-space-storage');
dbRequest.onsuccess = async function(event) {
const db = event.target.result;
try {
const transaction = db.transaction(['storage'], 'readwrite');
const store = transaction.objectStore('storage');
// Get all keys
const allKeys = await store.getAllKeys();
// Delete all space-related keys
for (const key of allKeys) {
if (key.startsWith('space_') || key.startsWith('universe_')) {
await store.delete(key);
console.log(`Deleted: ${key}`);
}
}
// Also clear sync queue
await store.delete('core-angular:sync:queue');
console.log('✅ Space data and sync queue cleared!');
console.log('🔄 Reloading page...');
setTimeout(() => location.reload(), 1000);
} catch (error) {
console.error('Failed to clear space data:', error);
}
};
dbRequest.onerror = function() {
console.error('Failed to open database');
};
🔍 Verify Cleanup
After running the script and reloading:
- Check Console - Should see no "undefined entity" errors
- Check Application Storage:
- DevTools → Application → IndexedDB → gograb-space-storage
- Should be empty or have only fresh data
- Check Network - Should see API calls to
/spaces/initialize
⚠️ Important Notes
Which Option Should I Use?
| Scenario | Recommended Option | Reason |
|---|---|---|
| First time fixing | Option 1 (Clear Everything) | Ensures completely clean state |
| Preserve local changes | Option 2 (Queue Only) | Keeps local data, clears queue |
| Fetch fresh from backend | Option 3 (Spaces Only) | Clears spaces, keeps settings |
What Happens After Clearing?
- Page reloads automatically
- Backend authentication occurs
- Space initialization fetches or creates space
- Sync begins with clean queue
- Data merges intelligently from backend
If You See Errors After Clearing
If you still see issues after clearing:
- Hard reload: Ctrl+Shift+R (Windows/Linux) or Cmd+Shift+R (Mac)
- Disable cache: DevTools → Network → Disable cache
- Incognito mode: Test in a fresh incognito window
- Check backend: Verify backend is running and accessible
🛠️ Troubleshooting
Error: "Failed to open database"
Solution: Database might be locked. Close all tabs with the application and try again.
Error: "Transaction failed"
Solution: Use Option 1 (Clear Everything) instead.
Error: "Cannot read property 'objectStore'"
Solution: The database structure might be different. Use Option 1 (Clear Everything).
No Errors but Still Seeing Issues
Solution:
- Clear browser cache completely
- Close ALL browser tabs with the application
- Reopen in a single tab
- Run Option 1 (Clear Everything)
📋 Manual Steps (If Scripts Fail)
If the scripts don't work, you can manually clear data:
- Open DevTools (F12)
- Go to Application tab
- IndexedDB → Right-click
gograb-space-storage→ Delete database - Local Storage → Right-click → Clear
- Session Storage → Right-click → Clear
- Reload page (Ctrl+R)
🎯 After Cleanup
Once you've cleared the corrupted data:
- ✅ Verify: Console should be clean (no "undefined entity" errors)
- ✅ Test: Create a new universe
- ✅ Confirm: Check backend has the data (API call should show success)
- ✅ Multi-browser: Open in different browser, should see same space
📚 Related Documentation
Last Updated: November 17, 2025
Status: Ready for Use