Code change:
this._storageListener.dispose(); } <del> $getValue<T>(shared: boolean, key: string): Promise<T | undefined> { </del> <ins> async $getValue<T>(shared: boolean, key: string): Promise<T | undefined> { </ins> if (shared) { this._sharedStorageKeysToWatch.set(key, true); } <del> try { return Promise.resolve(this._getValue<T>(shared, key)); } catch (error) { return Promise.reject(error); } </del> <ins> return this._getValue<T>(shared, key); </ins> } private _getValue<T>(shared: boolean, key: string): T | undefined { const jsonValue = this._storageService.get(key, shared ? StorageScope.GLOBAL : StorageScope.WORKSPACE); <del> if (!jsonValue) { return undefined; </del> <ins> if (jsonValue) { try { return JSON.parse(jsonValue); } catch (error) { // Do not fail this call but log it for diagnostics // https://github.com/microsoft/vscode/issues/132777 this._logService.error(`[mainThreadStorage] unexpected error parsing storage contents (key: ${key}, shared: ${shared}): ${error}`); } </ins> } <del> return JSON.parse(jsonValue); </del> <ins> return undefined; </ins> } <del> $setValue(shared: boolean, key: string, value: object): Promise<void> { let jsonValue: string; try { jsonValue = JSON.stringify(value); // Extension state is synced separately through extensions this._storageService.store(key, jsonValue, shared ? StorageScope.GLOBAL : StorageScope.WORKSPACE, StorageTarget.MACHINE); } catch (err) { return Promise.reject(err); } return Promise.resolve(undefined); </del> <ins> async $setValue(shared: boolean, key: string, value: object): Promise<void> { this._storageService.store(key, JSON.stringify(value), shared ? StorageScope.GLOBAL : StorageScope.WORKSPACE, StorageTarget.MACHINE /* Extension state is synced separately through extensions */); </ins> } $registerExtensionStorageKeysToSync(extension: IExtensionIdWithVersion, keys: string[]): void {

Related discussion:
text: The JSON is written a few lines lower, so it is unexpected that the value is corrupted. This might indicate some kind of bug in the storage layer. I don't remember writing that code, did you perhaps write that? Do you think it is so important such to fail extension activation when the JSON is corrupt, or should we catch that exception and return ?
I would suggest to be more resilient in extension activation as you suggest and fallback to an empty object here if any error rises from but log it as error: This is the first time I hear about a problem with persisting data into SQLite. However, seeing makes me think that this is not an officially supported Linux distribution.
curious if you could share the following 2 files with me (via e-mail is fine: find it on ). Steps: open the VSCode window where this issue happens View Command Palette =Log Storage Database Contents Help Toggle Dev Tools Find the 2 paths for the DBs send both files to me
I can still see the original issue in vscode-insiders v1.61.0-insider
whats the exact version you are on? And is it the issue that the extension fails to activate?
Version: 1.61.0-insider (user setup) Commit: Date: 2021-09-16T08:31:28.161Z Electron: 13.4.0 Chrome: 91.0.4472.164 14.16.0 V8: 9.1.269.39-electron.0 OS: WindowsNT x64 10.0. python extension: v2021.9. Error 2021-09-16 17:51:12: Error discovering pytest tests: [SyntaxError: Unexpected token S in JSON at position at (<anonymous) at a.runTestDiscovery (PATH.vscode-insidersextensionsms-outclient) at runMicrotasks (<anonymous) at processTicksAndRejections () at async (index 0) at async _.refreshTestData (PATH.vscode-insidersextensionsms-outclient) at async v.refreshTestDataInternal (PATH.vscode-insidersextensionsms-outclient)] { stdout: '[{"rootid": ".", "root": "...
I fixed the issue as reported in that extensions fail to activate when the contents in storage fail to get parsed.