Interface WithTimeout<Timeouts>

Overview

Lets you specify timeouts for individual methods, in two different formats:

  • A subtype of TimeoutDescriptor, which lets you specify the timeout for specific categories.
  • A number, which specifies the "happy path" timeout for the method.
    • In single-call methods, this sets both the request & overall method timeouts.
    • In multi-call methods, this sets the overall method timeout (request timeouts are kept as default).

Example

// Both `requestTimeoutMs` and `generalMethodTimeoutMs` are set to 1000ms.
await coll.insertOne({ ... }, { timeout: 1000 });

// `requestTimeoutMs` is left as default, `generalMethodTimeoutMs` is set to 2000ms.
await coll.insertOne({ ... }, { timeout: { generalMethodTimeoutMs: 2000 } });

// Both `requestTimeoutMs` and `generalMethodTimeoutMs` are set to 2000ms.
await coll.insertMany([...], {
  timeout: { requestTimeoutMs: 2000, generalMethodTimeoutMs: 2000 },
});

Example

// `requestTimeoutMs` is left as default, `generalMethodTimeoutMs` is set to 2000ms.
await coll.insertMany([...], { timeout: 2000 });

// `requestTimeoutMs` is left as default, `generalMethodTimeoutMs` is set to 2000ms.
await coll.insertMany([...], { timeout: { generalMethodTimeoutMs: 2000 } });

// Both `requestTimeoutMs` and `generalMethodTimeoutMs` are set to 2000ms.
await coll.insertMany([...], {
  timeout: { requestTimeoutMs: 2000, generalMethodTimeoutMs: 2000 },
});

See TimeoutDescriptor for much more information.

See

TimeoutDescriptor

interface WithTimeout<Timeouts> {
    timeout?: number | Pick<Partial<TimeoutDescriptor>, Timeouts | "requestTimeoutMs">;
}

Type Parameters

Hierarchy (view full)

Properties

Properties

timeout?: number | Pick<Partial<TimeoutDescriptor>, Timeouts | "requestTimeoutMs">

The method timeout override.

See TimeoutDescriptor for much more information.