Skip to content

Commit 22c740c

Browse files
committed
Retest the pattern in the code as well
1 parent 5d58a90 commit 22c740c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

_extension/src/client.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,16 @@ export class Client {
103103
const pprofDir = config.get<string>("pprofDir");
104104
const pprofArgs = pprofDir ? ["--pprofDir", pprofDir] : [];
105105

106-
// Get goMemLimit
107106
const goMemLimit = config.get<string>("goMemLimit");
108-
const env = goMemLimit ? { ...process.env, GOMEMLIMIT: goMemLimit } : process.env;
109107
if (goMemLimit) {
108+
// Keep this regex aligned with the pattern in package.json.
109+
if (!/^[0-9]+[KMGT]iB$/.test(goMemLimit)) {
110+
throw new Error("Invalid goMemLimit. Must be a valid memory limit (e.g., '2048MiB', '4GiB').");
111+
}
110112
this.outputChannel.appendLine(`Setting GOMEMLIMIT=${goMemLimit}`);
111113
}
114+
const env = goMemLimit ? { ...process.env, GOMEMLIMIT: goMemLimit } : process.env;
115+
112116

113117
const serverOptions: ServerOptions = {
114118
run: {

0 commit comments

Comments
 (0)