ubus. deferred

Represents a deferred ubus request.

A deferred request is created when invoking a method asynchronously using defer() or defer(). Instead of blocking and waiting for the result, the operation returns immediately with a deferred object that can be used to:

  • Check if the request has completed (completed())
  • Wait synchronously for completion (await())
  • Abort the pending request if no longer needed (abort())

This pattern is useful for:

  • Non-blocking operations in event-driven applications
  • Timeout handling and request cancellation
  • Concurrent execution of multiple ubus method calls
Examples
const req = defer(…);

req.await();
req.completed();
req.abort();
// Typical async pattern with callback
const req = conn.defer("system", "info", {}, (rc, data) => {
    if (rc == 0)
        printf("Info: %.J\n", data);
});
See

Methods

abort() → {boolean}

Abort a pending deferred request.

Cancels an asynchronous request that has not yet completed.

Returns true if the request was aborted.

Returns false if the request was already completed.

Returns: boolean

await() → {boolean}

Wait synchronously for a deferred request to complete.

Blocks until the deferred request completes or times out.

Returns true if the request completed.

Returns false if the request was already completed.

Returns: boolean

completed() → {boolean}

Check if a deferred request has completed.

Returns true if the deferred request has finished.

Returns false if the request is still pending.

Returns: boolean