Skip to content

Allow http.New to succeed even if connection is not ready (Defer Connection Errors to Runtime) #254

@pablomendezroyo

Description

@pablomendezroyo

Currently, the http.New(ctx context.Context, params ...Parameter) (client.Service, error) constructor attempts to establish a connection to the beacon node and returns an error if the node is not reachable or not ready at the time of creation. This behavior makes it difficult to use the client in applications that want to proceed with initialization even if the beacon node is temporarily unavailable, and only handle connection errors at runtime when making actual API calls.

Feature request:

Please consider adding an option (e.g., AllowDelayedStart or similar) to allow http.New to always succeed, even if the beacon node is not reachable at creation time.
The client should internally handle connection state and return errors from API methods if the node is not available, rather than failing at construction.
This would enable applications to initialize all dependencies up front, and handle connection issues gracefully at runtime, improving resilience and flexibility.

Example use case

svc, err := http.New(ctx, http.WithAddress(endpoint), http.WithAllowDelayedStart(true))
if err != nil {
    // Only fail for truly invalid parameters, not for connection state.
    log.Fatalf("Failed to create client: %v", err)
}
// ... later, handle connection errors from svc methods as needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions