* Wait for a handshake from the child then reply.
(child: cp.ChildProcess)
| 348 | * Wait for a handshake from the child then reply. |
| 349 | */ |
| 350 | private async handshake(child: cp.ChildProcess): Promise<void> { |
| 351 | if (!this.args) { |
| 352 | throw new Error("started without args") |
| 353 | } |
| 354 | const message = await onMessage<ChildMessage, ChildHandshakeMessage>( |
| 355 | child, |
| 356 | (message): message is ChildHandshakeMessage => { |
| 357 | return message.type === "handshake" |
| 358 | }, |
| 359 | this.logger, |
| 360 | ) |
| 361 | this.logger.debug("got message", field("message", message)) |
| 362 | this.send(child, { type: "handshake", args: this.args }) |
| 363 | } |
| 364 | |
| 365 | /** |
| 366 | * Send a message to the child. |