INNER CODE UNIT · TypeScript

forceTimer

yagop/node-telegram-bot-api · src/node/server.ts:98

  const forceTimer = setTimeout(() => server.closeAllConnections?.(), timeoutMs);
  forceTimer.unref?.(); // don't let the timer itself hold the loop open
  return forceTimer;
}

/**
 * Managed webhook runner: create a `node:http` webhook server, start listening,
 * and resolve when it shuts down. Once listening, installs `SIGINT`/`SIGTERM`
 * handlers that close the server for a graceful exit (cleaned up in a `finally`),
 * mirroring `run()` for long polling. Rejects if the server fails to start (e.g.
 * the port is in use).
 *
 * Shutdown cannot hang: `server.close()` waits for existing connections to end,
 * so we also drop idle keep-alive sockets at once and force-close anything still
 * busy past `shutdownTimeoutMs`.
 *
 * You still register the webhook with Telegram yourself, pointing at this server's
 * public URL (terminate TLS at a proxy/tunnel in front of it):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…