Skip to content

Commit 73cb236

Browse files
committed
Add back local storage patch
And fix the workspace bug. It is caused by an issue with how some global variables are being used asynchronously and is exacerbated by the delay reading settings from the remote introduces. 1. The workspace is created and is marked as not initialized. 2. The configuration's change handler is triggered, and now initialization is complete. 3. The handler tries to set the global workspace variable to initialized but the workspace has not been set yet so we get an undefined error. 4. The workspace global is now set, but it is set to the old value with initialized still set to false. 5. Workspace is never marked as initialized until something else triggers the on change handler again. Fixes #3061, and closes #6546. My guess is this logic changed in one of the VS Code updates, introducing this async bug but never getting caught probably because for them the settings are always local thus minimal delay.
1 parent 9ba66ec commit 73cb236

File tree

5 files changed

+106
-15
lines changed

5 files changed

+106
-15
lines changed

patches/disable-downloads.diff

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Index: code-server/lib/vscode/src/vs/workbench/browser/web.api.ts
1212
===================================================================
1313
--- code-server.orig/lib/vscode/src/vs/workbench/browser/web.api.ts
1414
+++ code-server/lib/vscode/src/vs/workbench/browser/web.api.ts
15-
@@ -276,6 +276,11 @@ export interface IWorkbenchConstructionO
15+
@@ -281,6 +281,11 @@ export interface IWorkbenchConstructionO
1616
*/
17-
readonly configurationDefaults?: Record<string, any>;
17+
readonly userDataPath?: string
1818

1919
+ /**
2020
+ * Whether the "Download..." option is enabled for files.
@@ -40,9 +40,9 @@ Index: code-server/lib/vscode/src/vs/workbench/services/environment/browser/envi
4040
* Gets whether a resolver extension is expected for the environment.
4141
*/
4242
readonly expectsResolverExtension: boolean;
43-
@@ -110,6 +115,13 @@ export class BrowserWorkbenchEnvironment
44-
@memoize
45-
get cacheHome(): URI { return joinPath(this.userRoamingDataHome, 'caches'); }
43+
@@ -111,6 +116,13 @@ export class BrowserWorkbenchEnvironment
44+
return this.options.userDataPath;
45+
}
4646

4747
+ get isEnabledFileDownloads(): boolean {
4848
+ if (typeof this.options.isEnabledFileDownloads === "undefined") {
@@ -52,7 +52,7 @@ Index: code-server/lib/vscode/src/vs/workbench/services/environment/browser/envi
5252
+ }
5353
+
5454
@memoize
55-
get workspaceStorageHome(): URI { return joinPath(this.userRoamingDataHome, 'workspaceStorage'); }
55+
get argvResource(): URI { return joinPath(this.userRoamingDataHome, 'argv.json'); }
5656

5757
Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
5858
===================================================================
@@ -78,10 +78,10 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
7878
===================================================================
7979
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
8080
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
81-
@@ -331,6 +331,7 @@ export class WebClientServer {
82-
const workbenchWebConfiguration = {
81+
@@ -332,6 +332,7 @@ export class WebClientServer {
8382
remoteAuthority,
8483
webviewEndpoint: vscodeBase + this._staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
84+
userDataPath: this._environmentService.userDataPath,
8585
+ isEnabledFileDownloads: !this._environmentService.args['disable-file-downloads'],
8686
_wrapWebWorkerExtHostInIframe,
8787
developmentOptions: { enableSmokeTestDriver: this._environmentService.args['enable-smoke-test-driver'] ? true : undefined, logLevel: this._logService.getLevel() },

patches/display-language.diff

+2-2
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
220220
import { CharCode } from 'vs/base/common/charCode';
221221
import { getRemoteServerRootPath } from 'vs/platform/remote/common/remoteHosts';
222222
import { IExtensionManifest } from 'vs/platform/extensions/common/extensions';
223-
@@ -343,6 +344,8 @@ export class WebClientServer {
223+
@@ -344,6 +345,8 @@ export class WebClientServer {
224224
callbackRoute: this._callbackRoute
225225
};
226226

@@ -229,7 +229,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
229229
const nlsBaseUrl = this._productService.extensionsGallery?.nlsBaseUrl;
230230
const values: { [key: string]: string } = {
231231
WORKBENCH_WEB_CONFIGURATION: asJSON(workbenchWebConfiguration),
232-
@@ -351,6 +354,7 @@ export class WebClientServer {
232+
@@ -352,6 +355,7 @@ export class WebClientServer {
233233
WORKBENCH_NLS_BASE_URL: vscodeBase + (nlsBaseUrl ? `${nlsBaseUrl}${!nlsBaseUrl.endsWith('/') ? '/' : ''}${this._productService.commit}/${this._productService.version}/` : ''),
234234
BASE: base,
235235
VS_BASE: vscodeBase,

patches/getting-started.diff

+5-5
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Index: code-server/lib/vscode/src/vs/workbench/browser/web.api.ts
135135
===================================================================
136136
--- code-server.orig/lib/vscode/src/vs/workbench/browser/web.api.ts
137137
+++ code-server/lib/vscode/src/vs/workbench/browser/web.api.ts
138-
@@ -281,6 +281,11 @@ export interface IWorkbenchConstructionO
138+
@@ -286,6 +286,11 @@ export interface IWorkbenchConstructionO
139139
*/
140140
readonly isEnabledFileDownloads?: boolean
141141

@@ -163,7 +163,7 @@ Index: code-server/lib/vscode/src/vs/workbench/services/environment/browser/envi
163163
* Gets whether a resolver extension is expected for the environment.
164164
*/
165165
readonly expectsResolverExtension: boolean;
166-
@@ -122,6 +127,13 @@ export class BrowserWorkbenchEnvironment
166+
@@ -123,6 +128,13 @@ export class BrowserWorkbenchEnvironment
167167
return this.options.isEnabledFileDownloads;
168168
}
169169

@@ -175,7 +175,7 @@ Index: code-server/lib/vscode/src/vs/workbench/services/environment/browser/envi
175175
+ }
176176
+
177177
@memoize
178-
get workspaceStorageHome(): URI { return joinPath(this.userRoamingDataHome, 'workspaceStorage'); }
178+
get argvResource(): URI { return joinPath(this.userRoamingDataHome, 'argv.json'); }
179179

180180
Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
181181
===================================================================
@@ -201,9 +201,9 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
201201
===================================================================
202202
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
203203
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
204-
@@ -334,6 +334,7 @@ export class WebClientServer {
205-
remoteAuthority,
204+
@@ -335,6 +335,7 @@ export class WebClientServer {
206205
webviewEndpoint: vscodeBase + this._staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
206+
userDataPath: this._environmentService.userDataPath,
207207
isEnabledFileDownloads: !this._environmentService.args['disable-file-downloads'],
208208
+ isEnabledCoderGettingStarted: !this._environmentService.args['disable-getting-started-override'],
209209
_wrapWebWorkerExtHostInIframe,

patches/local-storage.diff

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
Make storage local to the remote server
2+
3+
This makes user settings will be stored in the file system instead of in browser
4+
storage. Using browser storage makes sharing or seeding settings between
5+
browsers difficult and remote settings is not a sufficient replacement because
6+
some settings are only allowed to be set on the user level.
7+
8+
Unfortunately this does not affect state which uses a separate method with
9+
IndexedDB and does not appear nearly as easy to redirect to disk.
10+
11+
To test change settings from the UI and on disk while making sure they appear on
12+
the other side.
13+
14+
This patch also resolves a bug where a global value for workspace initialization
15+
is used in a non async-safe way.
16+
17+
Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
18+
===================================================================
19+
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
20+
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
21+
@@ -327,6 +327,7 @@ export class WebClientServer {
22+
const workbenchWebConfiguration = {
23+
remoteAuthority,
24+
webviewEndpoint: vscodeBase + this._staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
25+
+ userDataPath: this._environmentService.userDataPath,
26+
_wrapWebWorkerExtHostInIframe,
27+
developmentOptions: { enableSmokeTestDriver: this._environmentService.args['enable-smoke-test-driver'] ? true : undefined, logLevel: this._logService.getLevel() },
28+
settingsSyncOptions: !this._environmentService.isBuilt && this._environmentService.args['enable-sync'] ? { enabled: true } : undefined,
29+
Index: code-server/lib/vscode/src/vs/workbench/browser/web.api.ts
30+
===================================================================
31+
--- code-server.orig/lib/vscode/src/vs/workbench/browser/web.api.ts
32+
+++ code-server/lib/vscode/src/vs/workbench/browser/web.api.ts
33+
@@ -276,6 +276,11 @@ export interface IWorkbenchConstructionO
34+
*/
35+
readonly configurationDefaults?: Record<string, any>;
36+
37+
+ /**
38+
+ * Path to the user data directory.
39+
+ */
40+
+ readonly userDataPath?: string
41+
+
42+
//#endregion
43+
44+
//#region Profile options
45+
Index: code-server/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts
46+
===================================================================
47+
--- code-server.orig/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts
48+
+++ code-server/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts
49+
@@ -102,7 +102,14 @@ export class BrowserWorkbenchEnvironment
50+
get logFile(): URI { return joinPath(this.windowLogsPath, 'window.log'); }
51+
52+
@memoize
53+
- get userRoamingDataHome(): URI { return URI.file('/User').with({ scheme: Schemas.vscodeUserData }); }
54+
+ get userRoamingDataHome(): URI { return joinPath(URI.file(this.userDataPath).with({ scheme: Schemas.vscodeRemote }), 'User'); }
55+
+
56+
+ get userDataPath(): string {
57+
+ if (!this.options.userDataPath) {
58+
+ throw new Error('userDataPath was not provided to the browser');
59+
+ }
60+
+ return this.options.userDataPath;
61+
+ }
62+
63+
@memoize
64+
get argvResource(): URI { return joinPath(this.userRoamingDataHome, 'argv.json'); }
65+
Index: code-server/lib/vscode/src/vs/workbench/services/configuration/browser/configurationService.ts
66+
===================================================================
67+
--- code-server.orig/lib/vscode/src/vs/workbench/services/configuration/browser/configurationService.ts
68+
+++ code-server/lib/vscode/src/vs/workbench/services/configuration/browser/configurationService.ts
69+
@@ -143,8 +143,10 @@ export class WorkspaceService extends Di
70+
this.workspaceConfiguration = this._register(new WorkspaceConfiguration(configurationCache, fileService, uriIdentityService, logService));
71+
this._register(this.workspaceConfiguration.onDidUpdateConfiguration(fromCache => {
72+
this.onWorkspaceConfigurationChanged(fromCache).then(() => {
73+
- this.workspace.initialized = this.workspaceConfiguration.initialized;
74+
- this.checkAndMarkWorkspaceComplete(fromCache);
75+
+ if (this.workspace) { // The workspace may not have been created yet.
76+
+ this.workspace.initialized = this.workspaceConfiguration.initialized;
77+
+ this.checkAndMarkWorkspaceComplete(fromCache);
78+
+ }
79+
});
80+
}));
81+
82+
@@ -550,6 +552,8 @@ export class WorkspaceService extends Di
83+
previousFolders = this.workspace.folders;
84+
this.workspace.update(workspace);
85+
} else {
86+
+ // The configuration could have updated before the promise resolved.
87+
+ workspace.initialized = this.workspaceConfiguration.initialized;
88+
this.workspace = workspace;
89+
}
90+

patches/series

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ logout.diff
1010
store-socket.diff
1111
proxy-uri.diff
1212
unique-db.diff
13+
local-storage.diff
1314
service-worker.diff
1415
sourcemaps.diff
1516
disable-downloads.diff

0 commit comments

Comments
 (0)