Skip to content

Commit fc1ea4c

Browse files
Disable document symbol request for files over 1MB (#3430)
* feat: disable document symbol request for files over 1MB * Update packages/vscode-graphql/package.json
1 parent 7daa163 commit fc1ea4c

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

packages/graphql-language-service-server/src/MessageProcessor.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,22 @@ export class MessageProcessor {
837837
return [];
838838
}
839839

840+
if (
841+
this._settings.largeFileThreshold !== undefined &&
842+
this._settings.largeFileThreshold <
843+
cachedDocument.contents[0].query.length
844+
) {
845+
return [];
846+
}
847+
848+
this._logger.log(
849+
JSON.stringify({
850+
type: 'usage',
851+
messageType: 'textDocument/documentSymbol',
852+
fileName: textDocument.uri,
853+
}),
854+
);
855+
840856
return this._languageService.getDocumentSymbols(
841857
cachedDocument.contents[0].query,
842858
textDocument.uri,

packages/vscode-graphql/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@
9393
],
9494
"description": "Use a cached file output of your graphql-config schema result for definition lookups, symbols, outline, etc. Disabled by default."
9595
},
96+
"vscode-graphql.largeFileThreshold": {
97+
"type": [
98+
"number"
99+
],
100+
"description": "Disables outlining and other expensive operations for files larger than this threshold (in bytes). Defaults to 1000000 (one million).",
101+
"default": 1000000
102+
},
96103
"vscode-graphql.rejectUnauthorized": {
97104
"type": [
98105
"boolean"

0 commit comments

Comments
 (0)