Skip to content

hyperdrive: clarity client.end() / closing clients #28159

Description

@elithrar

Existing documentation URL(s)

#28121 and all related pages

What changes are you suggesting?

When using Hyperdrive: You do not have to call client.end() or sql.end() (or similar) - Workers <> Hyperdrive connections will be cleaned up when the request or invocation ends (such as a Workflow or Queue) or Durable Object hiberates/is evicted when idle.

Add a :::note[Create database clients inside your handlers] note that clarifies that you do NOT need to create a database connection in the global scope. Workers do not allow [I/O context](link to relevant Workers docs] to be used across requests, and Hyperdrive's distributed connection pooling solves for connection startup/cold connection latency. Using a driver-level pool in the global script scope will leave you with invalid connections that result in failed queries and hard errors.

Fix all examples to comply.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions