( hostname: string, port: number, https: boolean, triggerApi: TriggerApi, spinner: Ora )
| 524 | let yaltTunnel: YaltTunnel | null = null; |
| 525 | |
| 526 | async function createNativeTunnel( |
| 527 | hostname: string, |
| 528 | port: number, |
| 529 | https: boolean, |
| 530 | triggerApi: TriggerApi, |
| 531 | spinner: Ora |
| 532 | ) { |
| 533 | try { |
| 534 | const response = await triggerApi.createTunnel(); |
| 535 | |
| 536 | // import WS dynamically |
| 537 | const WebSocket = await import("ws"); |
| 538 | |
| 539 | yaltTunnel = new YaltTunnel( |
| 540 | response.url, |
| 541 | `${hostname}:${port}`, |
| 542 | https, |
| 543 | { |
| 544 | WebSocket: WebSocket.default, |
| 545 | connectionTimeout: getConnectionTimeoutValue(), |
| 546 | maxRetries: 10, |
| 547 | }, |
| 548 | { verbose: process.env.TUNNEL_VERBOSE === "1" } |
| 549 | ); |
| 550 | |
| 551 | await yaltTunnel.connect(); |
| 552 | |
| 553 | return `https://${response.url}`; |
| 554 | } catch (e) { |
| 555 | spinner.fail(`Failed to create tunnel.\n${e}`); |
| 556 | return; |
| 557 | } |
| 558 | } |
| 559 | |
| 560 | function getConnectionTimeoutValue() { |
| 561 | if (typeof process.env.TUNNEL_CONNECTION_TIMEOUT === "string") { |
no test coverage detected
searching dependent graphs…