Skip to content

Deno KV: Limitation of backoffSchedule and confusing error message #27536

@kitsonk

Description

@kitsonk

Version: Deno 2.1.4

Deno has a limit of a backoff schedule of 5 or less intervals. This limit is not documented and the error is uniformative and requires reading the code to actually determine the limit.

For example the following code:

const db = await Deno.open();
await db.enqueue("test", {
  backoffSchedule: [1000, 2000, 4000, 8000, 16000, 32000]
});

Will produce the following error, giving the user no indication of what the problem is:

TypeError: Invalid backoffSchedule
    await db.enqueue("test", {
             ^
    at validateBackoffSchedule (ext:deno_kv/01_db.ts:29:11)
    at Kv.enqueue (ext:deno_kv/01_db.ts:161:7)
    at Router.enqueue (file:///Users/kitsonk/github/herd/mod.ts:285:21)
    at test.ts:1:10

Also, the limitation of 5 intervals makes it difficult to implement a standard 32 or 64 second exponential backoff (as it would require 6 or 7 intervals). It maybe worth considering catering to allow a common pattern of backoff.

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