-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Closed
Labels
debtCode quality issuesCode quality issuesfile-ioFile I/OFile I/Oinsiders-releasedPatch has been released in VS Code InsidersPatch has been released in VS Code InsidersverifiedVerification succeededVerification succeededwebIssues related to running VSCode in the webIssues related to running VSCode in the web
Milestone
Description
While fixing my storage service in web that is using IndexedDB I noticed that the user data provider leveraging IndexDB is checking whether the object store exists or not:
vscode/src/vs/platform/files/browser/indexedDBFileSystemProvider.ts
Lines 58 to 62 in be2f951
| if (!db.objectStoreNames.contains(store)) { | |
| console.error(`Error while creating indexedDB. Could not create ${store} object store`); | |
| c(null); | |
| return; | |
| } |
I wonder if you should adopt a similar strategy that I do by recreating the IndexDB and store so that the user is not ending up with an in-memory solution forever.
Here is my fix: 6c302fb
vscode/src/vs/platform/storage/browser/storageService.ts
Lines 252 to 276 in 6c302fb
| // It is still possible though that the object store | |
| // we expect is not there (seen in Safari). As such, | |
| // we validate the store is there and otherwise attempt | |
| // once to re-create. | |
| if (!db.objectStoreNames.contains(IndexedDBStorageDatabase.STORAGE_OBJECT_STORE)) { | |
| this.logService.error(`[IndexedDB Storage ${this.name}] onsuccess(): ${IndexedDBStorageDatabase.STORAGE_OBJECT_STORE} does not exist.`); | |
| if (retryOnError) { | |
| this.logService.info(`[IndexedDB Storage ${this.name}] onsuccess(): Attempting to recreate the DB once.`); | |
| // Close any opened connections | |
| db.close(); | |
| // Try to delete the db | |
| const deleteRequest = window.indexedDB.deleteDatabase(this.name); | |
| deleteRequest.onsuccess = () => this.doConnect(false /* do not retry anymore from here */).then(resolve, reject); | |
| deleteRequest.onerror = () => { | |
| this.logService.error(`[IndexedDB Storage ${this.name}] deleteDatabase(): ${deleteRequest.error}`); | |
| reject(deleteRequest.error); | |
| }; | |
| return; | |
| } | |
| } |
Metadata
Metadata
Assignees
Labels
debtCode quality issuesCode quality issuesfile-ioFile I/OFile I/Oinsiders-releasedPatch has been released in VS Code InsidersPatch has been released in VS Code InsidersverifiedVerification succeededVerification succeededwebIssues related to running VSCode in the webIssues related to running VSCode in the web