How does it work without await?

I have in

  public shared({caller = caller}) func delete(options: CanDB.DeleteOptions) {
    if (checkCaller(caller)) {
      CanDB.delete(db, options);

In it is called like:

    var db: DBPartition.DBPartition = actor(Principal.toText(paymentCanisterId));
    db.delete({sk = "p/" # Principal.toText(userId)}); // FIXME: `await`?

I wonder how an inter-canister call db.delete works without await (and even does not compile if I add await).

func delete looks like a synchronous call because I didn’t added result type async (), but isn’t it (as a shared function) async by default?

As I understand, inter-canister calls are always asynchronous.

I do not understand something.

It is a “one-way call” that has no response and can’t be awaited.

The implicit return type when no return type is given is (). These are equivalent:

public func f() { ... };
public func f() () { ... };

But () is different from async (). The latter creates an empty response which can be awaited. The former doesn’t create a response and cannot be awaited. Those are called one-way calls.

A public function can have return type () or async X, nothing else.

1 Like

You probably meant:

public func f() { ... };
public func f() : () { ... };

CanDB’s delete API is synchronous (within a single canister) and does not involve any inter-canister calls.