Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to set --max-old-space-size on server #1299

Merged
merged 3 commits into from May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion extensions/vscode-vue-language-features/package.json
Expand Up @@ -270,6 +270,14 @@
"default": false,
"description": "Use second server to progress heavy diagnostic works, the main server workhorse computing intellisense, operations such as auto-complete can respond faster. Note that this will lead to more memory usage."
},
"volar.vueserver.maxOldSpaceSize": {
"type": [
"number",
"null"
],
"default": null,
"description": "Set --max-old-space-size option on server process. If you have problem on frequently \"Request textDocument/** failed.\" error, try setting higher memory(MB) on it."
},
"volar.codeLens.references": {
"type": "boolean",
"default": true,
Expand Down Expand Up @@ -639,4 +647,4 @@
"vscode-languageclient": "^8.0.0-next.14",
"vscode-nls": "5.0.0"
}
}
}
28 changes: 24 additions & 4 deletions extensions/vscode-vue-language-features/src/common.ts
Expand Up @@ -95,6 +95,7 @@ async function doActivate(context: vscode.ExtensionContext, createLc: CreateLang
{ language: 'vue' },
];
const _useSecondServer = useSecondServer();
const _serverMaxOldSpaceSize = serverMaxOldSpaceSize();

apiClient = createLc(
'volar-language-features',
Expand All @@ -121,6 +122,7 @@ async function doActivate(context: vscode.ExtensionContext, createLc: CreateLang
const clients = [apiClient, docClient, htmlClient].filter(shared.notEmpty);

registerUseSecondServerChange();
registerServerMaxOldSpaceSizeChange();
registerRestartRequest();
registerClientRequests();

Expand All @@ -135,13 +137,27 @@ async function doActivate(context: vscode.ExtensionContext, createLc: CreateLang
tsconfig.activate(context, docClient ?? apiClient);
doctor.activate(context);

async function registerUseSecondServerChange() {
async function requestReloadVscode() {
const reload = await vscode.window.showInformationMessage(
'Please reload VSCode to restart language servers.',
'Reload Window'
);
if (reload === undefined) return; // cancel
vscode.commands.executeCommand('workbench.action.reloadWindow');
}
function registerUseSecondServerChange() {
vscode.workspace.onDidChangeConfiguration(async () => {
const nowUseSecondServer = useSecondServer();
if (_useSecondServer !== nowUseSecondServer) {
const reload = await vscode.window.showInformationMessage('Please reload VSCode to restart language servers.', 'Reload Window');
if (reload === undefined) return; // cancel
vscode.commands.executeCommand('workbench.action.reloadWindow');
return requestReloadVscode();
}
});
}
function registerServerMaxOldSpaceSizeChange() {
vscode.workspace.onDidChangeConfiguration(async () => {
const nowServerMaxOldSpaceSize = serverMaxOldSpaceSize();
if (_serverMaxOldSpaceSize !== nowServerMaxOldSpaceSize) {
return requestReloadVscode();
}
});
}
Expand Down Expand Up @@ -196,6 +212,10 @@ function useSecondServer() {
return !!vscode.workspace.getConfiguration('volar').get<boolean>('vueserver.useSecondServer');
}

function serverMaxOldSpaceSize() {
return vscode.workspace.getConfiguration('volar').get<number | null>('vueserver.maxOldSpaceSize');
}

function getInitializationOptions(
context: vscode.ExtensionContext,
mode: 'main-language-features' | 'second-language-features' | 'document-features',
Expand Down
11 changes: 10 additions & 1 deletion extensions/vscode-vue-language-features/src/nodeClientMain.ts
Expand Up @@ -12,9 +12,18 @@ export function activate(context: vscode.ExtensionContext) {
) => {

const serverModule = vscode.Uri.joinPath(context.extensionUri, 'server');
const maxOldSpaceSize = vscode.workspace.getConfiguration('volar').get<number | null>('vueserver.maxOldSpaceSize');
const runOptions = { execArgv: <string[]>[] };
if (maxOldSpaceSize) {
runOptions.execArgv.push("--max-old-space-size=" + maxOldSpaceSize);
}
const debugOptions = { execArgv: ['--nolazy', '--inspect=' + port] };
const serverOptions: lsp.ServerOptions = {
run: { module: serverModule.fsPath, transport: lsp.TransportKind.ipc },
run: {
module: serverModule.fsPath,
transport: lsp.TransportKind.ipc,
options: runOptions
},
debug: {
module: serverModule.fsPath,
transport: lsp.TransportKind.ipc,
Expand Down