MCPcopy
hub / github.com/triggerdotdev/trigger.dev / createNativeTunnel

Function createNativeTunnel

packages/cli/src/commands/dev.ts:526–558  ·  view source on GitHub ↗
(
  hostname: string,
  port: number,
  https: boolean,
  triggerApi: TriggerApi,
  spinner: Ora
)

Source from the content-addressed store, hash-verified

524let yaltTunnel: YaltTunnel | null = null;
525
526async 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
560function getConnectionTimeoutValue() {
561 if (typeof process.env.TUNNEL_CONNECTION_TIMEOUT === "string") {

Callers 1

resolveEndpointUrlFunction · 0.85

Calls 3

createTunnelMethod · 0.45
connectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…