Skip to content

Commit 8058194

Browse files
committed
sandbox - requestChannel is optional
1 parent 4e31ae7 commit 8058194

File tree

1 file changed

+10
-5
lines changed
  • src/vs/base/parts/ipc/electron-sandbox

1 file changed

+10
-5
lines changed

src/vs/base/parts/ipc/electron-sandbox/ipc.mp.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ interface IMessageChannelResult {
1313
source: unknown;
1414
}
1515

16-
export async function acquirePort(requestChannel: string, responseChannel: string): Promise<MessagePort> {
17-
18-
// Ask to create message channel inside the window
19-
// and send over a UUID to correlate the response
16+
export async function acquirePort(requestChannel: string | undefined, responseChannel: string): Promise<MessagePort> {
2017
const nonce = generateUuid();
18+
19+
// Get ready to acquire the message port from the
20+
// provided `responseChannel` via preload helper.
2121
ipcMessagePort.acquire(responseChannel, nonce);
22-
ipcRenderer.send(requestChannel, nonce);
22+
23+
// If a `requestChannel` is provided, we are in charge
24+
// to trigger acquisition of the message port from main
25+
if (typeof requestChannel === 'string') {
26+
ipcRenderer.send(requestChannel, nonce);
27+
}
2328

2429
// Wait until the main side has returned the `MessagePort`
2530
// We need to filter by the `nonce` to ensure we listen

0 commit comments

Comments
 (0)