vuejs/devtools-v6 · error · Error
Storage wasn't initialized with 'init()'
Error message
Storage wasn't initialized with 'init()'
What it means
The shared storage utility wraps localStorage (or an in-memory fallback) and only loads data into `storageData` during init(). checkStorage() throws this when get/set/remove/clear is called before init(), because there is nowhere to read or write values. It is a lifecycle guard, not a data error.
Source
Thrown at packages/shared-utils/src/storage.ts:82
}
export function clearStorage() {
checkStorage()
if (useStorage) {
storageData = {}
target.chrome.storage.local.clear()
}
else {
try {
localStorage.clear()
}
catch (e) {}
}
}
function checkStorage() {
if (!storageData) {
throw new Error('Storage wasn\'t initialized with \'init()\'')
}
}
function getDefaultValue(value, defaultValue) {
if (value == null) {
return defaultValue
}
return value
}
View on GitHub (pinned to dd2ab5d427)
Solutions
- Call and await `init()` from shared-utils storage before any other storage call, ideally at application startup.
- Ensure init() actually succeeds: in browsers with localStorage blocked (private browsing) provide a storage shim or in-memory fallback.
- Move storage reads/writes out of module top-level code into a post-init lifecycle hook.
- Wrap storage access in a helper that lazily calls init() if storageData is not yet loaded.
Example fix
// before
import { getStorage } from '@vue-devtools/shared-utils'
const lastApp = getStorage('last-open-app') // throws
// after
import { init, getStorage } from '@vue-devtools/shared-utils'
await init()
const lastApp = getStorage('last-open-app') Defensive patterns
Strategy: try-catch
Validate before calling
import { init } from '@vue-devtools/shared-utils'
await init() // before ANY get/set/remove/clearStorage call Type guard
function storageReady() { return !!storageData } // or expose/init-check equivalent Try / catch
try {
setStorage('key', value)
} catch (e) {
if (String(e).includes("init()")) { await init(); setStorage('key', value) }
else throw e
} Prevention
- Await init() as the first step of app startup
- Never call storage helpers from module top-level code
- Provide an in-memory shim when localStorage is unavailable (private mode/SSR)
- Note init() swallows load errors — verify it succeeded before use
When it happens
Trigger: Calling getStorage, setStorage, removeStorage, or clearStorage before `await init()` (or when init() failed silently — its load errors are swallowed in a try/catch, leaving storageData undefined).
Common situations: Module-level code that reads a stored setting at import time before init() runs; forgetting to await the async init(); init() failing because localStorage is disabled (private mode, SSR without a shim) and the failure being caught and ignored.
AI-assisted analysis of vuejs/devtools-v6@dd2ab5d427 (2026-08-31).
Data as JSON: /api/errors/7e86ab2066fdf353.
Report an issue: GitHub.