Elffuss BraidHub

kikocis/continue public

run shell path async to avoid blocking config load
Changeset08608c2155bf4bfb9fb0e9bb5250f255a671424068672718d2b08ec04dddb9be
AuthorNate <sestinj@gmail.com> · 2025-07-03 23:07 -07:00
CommitterNate <sestinj@gmail.com> · 2025-07-03 23:07 -07:00
Parentsd26a03bcbf7f

Browse the files at this changeset

2 files changed

modified core/context/mcp/MCPConnection.ts +8 −4
@@ -47,7 +47,8 @@
4747 };
4848
4949 constructor(public options: MCPOptions) {
50- this.transport = this.constructTransport(options);
50+ // Don't construct transport in constructor to avoid blocking
51+ this.transport = {} as Transport; // Will be set in connectClient
5152
5253 this.client = new Client(
5354 {
@@ -132,7 +133,8 @@
132133 });
133134 }),
134135 (async () => {
135- this.transport = this.constructTransport(this.options);
136+ this.transport = await this.constructTransportAsync(this.options);
137+
136138 try {
137139 await this.client.connect(this.transport);
138140 } catch (error) {
@@ -295,7 +297,9 @@
295297 };
296298 }
297299
298- private constructTransport(options: MCPOptions): Transport {
300+ private async constructTransportAsync(
301+ options: MCPOptions,
302+ ): Promise<Transport> {
299303 switch (options.transport.type) {
300304 case "stdio":
301305 const env: Record<string, string> = options.transport.env
@@ -309,7 +313,7 @@
309313 // For non-Windows platforms, try to get the PATH from user shell
310314 if (process.platform !== "win32") {
311315 try {
312- const shellEnvPath = getEnvPathFromUserShell();
316+ const shellEnvPath = await getEnvPathFromUserShell();
313317 if (shellEnvPath && shellEnvPath !== process.env.PATH) {
314318 env.PATH = shellEnvPath;
315319 }
modified core/util/shellPath.ts +6 −5
@@ -1,7 +1,8 @@
1-import { execSync } from "child_process";
2-import { homedir } from "os";
3-
4-export function getEnvPathFromUserShell(): string | undefined {
1+import { exec } from "child_process";
2+import { promisify } from "util";
3+
4+const execAsync = promisify(exec);
5+export async function getEnvPathFromUserShell(): Promise<string | undefined> {
56 if (process.platform === "win32") {
67 console.warn(`${getEnvPathFromUserShell.name} not implemented for Windows`);
78 return undefined;
@@ -15,7 +16,7 @@
1516 // Source common profile files
1617 const command = `${process.env.SHELL} -l -c 'for f in ~/.zprofile ~/.zshrc ~/.bash_profile ~/.bashrc; do [ -f "$f" ] && source "$f" 2>/dev/null; done; echo $PATH'`;
1718
18- const stdout = execSync(command, {
19+ const { stdout } = await execAsync(command, {
1920 encoding: "utf8",
2021 });
2122