Skip to content

Commit 6d9445f

Browse files
1 parent f82bfc4 commit 6d9445f

2 files changed

Lines changed: 35 additions & 20 deletions

File tree

Source/Function/Install/Function/Install.ts

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -82,31 +82,44 @@ export default async function Install(): Promise<void> {
8282
console.log(
8383
`[Wind] MessagePort acquire: ${ResponseChannel}, nonce=${Nonce}`,
8484
);
85+
86+
// Only do the extension host handshake for the ext host channel.
87+
// Other acquires (utility process workers, file watchers) get a
88+
// port but no protocol — their stubs never resolve, so no crash.
89+
const IsExtensionHost = ResponseChannel.includes(
90+
"startExtensionHostMessagePortResult",
91+
);
92+
8593
const { port1, port2 } = new MessageChannel();
8694
window.postMessage(Nonce, "*", [port2]);
87-
port1.start();
88-
let Done = false;
89-
port1.onmessage = (Event: MessageEvent) => {
90-
if (Done) return;
91-
const Data = Event.data;
92-
const Length =
93-
Data instanceof ArrayBuffer
94-
? Data.byteLength
95-
: Data instanceof Uint8Array
95+
96+
if (IsExtensionHost) {
97+
port1.start();
98+
let Done = false;
99+
port1.onmessage = (Event: MessageEvent) => {
100+
if (Done) return;
101+
const Data = Event.data;
102+
const Length =
103+
Data instanceof ArrayBuffer
96104
? Data.byteLength
97-
: 0;
98-
if (Length > 1) {
99-
Done = true;
105+
: Data instanceof Uint8Array
106+
? Data.byteLength
107+
: 0;
108+
if (Length > 1) {
109+
Done = true;
110+
console.log(
111+
"[Wind] Extension host: received init data, sending Initialized",
112+
);
113+
port1.postMessage(new Uint8Array([1]));
114+
}
115+
};
116+
setTimeout(() => {
100117
console.log(
101-
"[Wind] Extension host: received init data, sending Initialized",
118+
"[Wind] Extension host: sending Ready",
102119
);
103-
port1.postMessage(new Uint8Array([1]));
104-
}
105-
};
106-
setTimeout(() => {
107-
console.log("[Wind] Extension host: sending Ready");
108-
port1.postMessage(new Uint8Array([2]));
109-
}, 50);
120+
port1.postMessage(new Uint8Array([2]));
121+
}, 50);
122+
}
110123
},
111124
},
112125
};

Source/Service/TauriMainProcessService.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ const StubChannels: Record<string, Record<string, unknown>> = {
149149
browserElements: {},
150150
NativeMcpDiscoveryHelper: { load: undefined },
151151
sandboxHelper: {},
152+
mcpGateway: {},
153+
browserViewGroup: {},
152154
};
153155

154156
// ============================================================================

0 commit comments

Comments
 (0)