Home / Function/ tryBindServer() — vite Function Reference

tryBindServer() — vite Function Reference

Architecture documentation for the tryBindServer() function in http.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  a534d144_3a64_04f3_2a9d_7f383d463d6b["tryBindServer()"]
  695bc011_d16d_4322_2fef_1a59a092ee32["http.ts"]
  a534d144_3a64_04f3_2a9d_7f383d463d6b -->|defined in| 695bc011_d16d_4322_2fef_1a59a092ee32
  de8a40a8_9bd5_6c8d_7e7e_82549c3ddf5f["httpServerStart()"]
  de8a40a8_9bd5_6c8d_7e7e_82549c3ddf5f -->|calls| a534d144_3a64_04f3_2a9d_7f383d463d6b
  style a534d144_3a64_04f3_2a9d_7f383d463d6b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/http.ts lines 191–215

async function tryBindServer(
  httpServer: HttpServer,
  port: number,
  host: string | undefined,
): Promise<
  { success: true } | { success: false; error: Error & { code?: string } }
> {
  return new Promise((resolve) => {
    const onError = (e: Error & { code?: string }) => {
      httpServer.off('error', onError)
      httpServer.off('listening', onListening)
      resolve({ success: false, error: e })
    }
    const onListening = () => {
      httpServer.off('error', onError)
      httpServer.off('listening', onListening)
      resolve({ success: true })
    }

    httpServer.on('error', onError)
    httpServer.on('listening', onListening)

    httpServer.listen(port, host)
  })
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does tryBindServer() do?
tryBindServer() is a function in the vite codebase, defined in packages/vite/src/node/http.ts.
Where is tryBindServer() defined?
tryBindServer() is defined in packages/vite/src/node/http.ts at line 191.
What calls tryBindServer()?
tryBindServer() is called by 1 function(s): httpServerStart.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free