Skip to content

Feature: pinger timeout #408

@LucyEgan

Description

@LucyEgan

Is your feature request related to a problem?

Use the pinger to flag unstable connections, that can be shown as quick feedback to the end user.

Currently when a connection is in a hung state as forcefully shown in chrome with "Offline" mid way through a connection, it has no way to know something is wrong since the calls done complete/timeout. (Below calls of sice 19B are all pings)

Image

Describe the solution

Since there's already a 30s hardcoded ping without a pong response being handled.
Exposing this further to be used for connection stability eg flaky mobile/wifi connections/general routing issues/packet loss.

Adding a event
.on('pong', (latency: number)=>{})
.on('connectionStability', (stability: Stability)=>{})

Adding options

{
    pinger: {
        interval: 30000,
        timeout: 5000,
        stableThreshold: 500,
    }
}

During the ping race the following
setTimout(pinger.stableThreshold) // store .connectionStability and fire connectionStability as UNSTABLE
reject on setTimout(pinger.timeout) // store .connectionStability and fire connectionStability as FAILED
resolve ping->pong // store .connectionStability and fire connectionStability as STABLE, store .pong and fire pong as ping runtime
finally // clear timeouts

Alternative methods

Implement as above but with a extra separate await .ping()

SurrealDB version

2.3.0+20250321

JavaScript SDK version

1.2.1

Contact Details

[email protected]

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions