(data: WS.RawData)
| 399 | await timeoutPromise( |
| 400 | new Promise<void>((resolve, reject) => { |
| 401 | const onMessage = (data: WS.RawData) => { |
| 402 | let message: unknown |
| 403 | try { |
| 404 | message = jsonParse(String(data)) |
| 405 | } catch (error) { |
| 406 | cleanup() |
| 407 | reject( |
| 408 | new Error( |
| 409 | `remote app server at ${this.args.websocketUrl} sent invalid initialize response: ${String(error)}`, |
| 410 | ), |
| 411 | ) |
| 412 | return |
| 413 | } |
| 414 | |
| 415 | if (isJsonRpcResponse(message) && message.id === INITIALIZE_REQUEST_ID) { |
| 416 | cleanup() |
| 417 | resolve() |
| 418 | return |
| 419 | } |
| 420 | if (isJsonRpcError(message) && message.id === INITIALIZE_REQUEST_ID) { |
| 421 | cleanup() |
| 422 | reject( |
| 423 | new Error( |
| 424 | `remote app server at ${this.args.websocketUrl} rejected initialize: ${message.error.message}`, |
| 425 | ), |
| 426 | ) |
| 427 | return |
| 428 | } |
| 429 | if (isJsonRpcNotification(message)) { |
| 430 | pendingEvents.push(appServerEventFromNotification(message)) |
| 431 | return |
| 432 | } |
| 433 | if (isJsonRpcRequest(message)) { |
| 434 | pendingEvents.push({ type: 'server_request', request: message }) |
| 435 | } |
| 436 | } |
| 437 | const onClose = () => { |
| 438 | cleanup() |
| 439 | reject( |
no test coverage detected