WebOfTrust / keria

KERI Agent in the cloud
https://keria.readthedocs.io/en/latest/
Apache License 2.0
17 stars 26 forks source link

Long running operation set to done before dependencies are done #200

Open lenkan opened 4 months ago

lenkan commented 4 months ago

Note sure if you would consider this a bug, but I thought I would flag it because the behavior is not expected to me.

Actual Behaviour

When an operation has dependencies, it's done status is set to true before the dependencies are done. For example, when an AID with witnesses is creating a registry, you get:

{
  name: 'registry.EMr2ZK2Y5CpACEM6iHJQPrI4oHk7xg6QjUK_Uw0YFFld',
  metadata: {
    anchor: {
      i: 'EHmDHffYsNVW8-T-IRD2zcLEopTcE96ZugeKWY_GdxRK',
      s: '0',
      d: 'EHmDHffYsNVW8-T-IRD2zcLEopTcE96ZugeKWY_GdxRK'
    },
    depends: {
      name: 'witness.EMr2ZK2Y5CpACEM6iHJQPrI4oHk7xg6QjUK_Uw0YFFld',
      metadata: [Object],
      done: false,
      error: null,
      response: null
    }
  },
  done: true,
  error: null,
  response: {
    anchor: {
      i: 'EHmDHffYsNVW8-T-IRD2zcLEopTcE96ZugeKWY_GdxRK',
      s: '0',
      d: 'EHmDHffYsNVW8-T-IRD2zcLEopTcE96ZugeKWY_GdxRK'
    }
  }
}

Notice how the top-level operation is done, but it's dependencies are not. The same happens when issuing credentials:

{
  name: 'credential.EAM5C0JG9_zpMhKg97t-Rw9QaeKiYpPPXhmQQXr0GM8m',
  metadata: {
    ced: {
      ...
    },
    depends: {
      name: 'witness.EAM5C0JG9_zpMhKg97t-Rw9QaeKiYpPPXhmQQXr0GM8m',
      metadata: { sn: 2 },
      done: false,
      error: null,
      response: null
    }
  },
  done: true,
  error: null,
  response: {
    ced: {
      ...
    }
  }
}

Expected behaviour

Top level operation done should also depend on its child operations. So something like this done = depends.done === true ? self.done : false

Notes

This could be implemented at client level of course. But i suspect others will run into the same issue unless this is well documented.

psteniusubi commented 4 months ago

There's a client side workaround for this in the integration tests

https://github.com/WebOfTrust/signify-ts/blob/6574f3089fdc95abd52ff08b43f569107ec1009f/examples/integration-scripts/utils/test-util.ts#L64-L82