reload

Bun

Symbol

TLSSocket.reload

reload(handler: SocketHandler): void

Reset the socket's callbacks. This is useful with bun --hot to facilitate hot reloading.

This will apply to all sockets from the same Listener. it is per socket only for Bun.connect.

Referenced types

interface SocketHandler<Data = unknown, DataBinaryType extends BinaryType = 'buffer'>

  • binaryType?: unknown

    Choose what ArrayBufferView is returned in the SocketHandler.data callback.

  • close(socket: Socket<Data>, error?: Error): void | Promise<void>
  • connectError(socket: Socket<Data>, error: Error): void | Promise<void>

    When the socket fails to be created, this function is called.

    The promise returned by Bun.connect rejects after this function is called.

    When connectError is specified, the rejected promise will not be added to the promise rejection queue (so it won't be reported as an unhandled promise rejection, since connectError handles it).

    When connectError is not specified, the rejected promise will be added to the promise rejection queue.

  • data(socket: Socket<Data>, data: BinaryTypeList[DataBinaryType]): void | Promise<void>
  • drain(socket: Socket<Data>): void | Promise<void>
  • end(socket: Socket<Data>): void | Promise<void>

    When the socket has been shutdown from the other end, this function is called. This is a TCP FIN packet.

  • error(socket: Socket<Data>, error: Error): void | Promise<void>
  • handshake(socket: Socket<Data>, success: boolean, authorizationError: null | Error): void

    When handshake is completed, this functions is called.

    @param success

    Indicates if the server authorized despite the authorizationError.

    @param authorizationError

    Certificate Authorization Error or null.

  • open(socket: Socket<Data>): void | Promise<void>

    Is called when the socket connects, or in case of TLS if no handshake is provided this will be called only after handshake

  • timeout(socket: Socket<Data>): void | Promise<void>

    Called when a message times out.