openwallet-foundation/credo-ts

[Question] Observe errors from agent

icc-romeu opened this issue ยท 4 comments

Hi,

I have been through the package and I did not find this. Is there an event I can listen to get the errors in processing messages/connections/proofs... Something like:

agent.events.on(AgentEventTypes.Errors, async (error) => ... )

It would be nice to give user some feedback of what happened, but I cannot find anything...

We have an AgentEventProcessed event which for a long time I'd like to extend to also include error states that occurred during processing.

So it will always emit the event for every received message, but can also contains errors etc..

https://github.com/openwallet-foundation/agent-framework-javascript/blob/ee34fe71780a0787db96e28575eeedce3b4704bd/packages/core/src/agent/Dispatcher.ts#L19

Would that solve your problem?

Let me check... If I can differentiate errors, yes. ๐Ÿ‘

Hi again, just tested and no luck. ๐Ÿ˜ž

Used this to check for events:

agent.events.on<AgentMessageProcessedEvent>(AgentEventTypes.AgentMessageProcessed, event => {
        console.log('[AgentMessageProcessed] ', event);
});

And forced an error, but... the event did not fire. What I saw came from the agent logger. So I assume that other events need to be captured in order to be able to observe processing errors.

 DEBUG  DEBUG: Agent received message
 DEBUG  DEBUG: Processing presentation request with id 1da94639-773a-4f60-86e1-4322edc84760
 LOG  isConnected => {"outOfBandRecord": {"_tags": [Object], "autoAcceptConnection": true, "createdAt": "2024-01-19T08:53:33.303Z", "id": "fddb8c9a-4829-43e1-a788-19961ae1c5f0", "metadata": [Object], "outOfBandInvitation": [Object], "reusable": false, "role": "receiver", "state": "prepare-response", "updatedAt": "2024-01-19T08:53:33.388Z"}}
 ERROR  ERROR: Error handling message with type https://didcomm.org/present-proof/1.0/request-presentation {
  "message": {
    "@type": "https://didcomm.org/present-proof/1.0/request-presentation",
    "comment": null,
    "request_presentations~attach": [
      {
        "@id": "libindy-request-presentation-0",
        "mime-type": "application/json",
        "data": {
          "base64": "whatever"
        }
      }
    ],
    "@id": "1da94639-773a-4f60-86e1-4322edc84760"
  },
  "error": {
    "name": "RecordNotFoundError",
    "message": "DidCommMessageRecord: No record found for given query '{\"associatedRecordId\":\"a9adb16d-b7b1-4587-9ef4-56373dc889fe\",\"messageName\":\"propose-presentation\",\"protocolName\":\"present-proof\",\"protocolMajorVersion\":\"1\"}'",
    "stack": "RecordNotFoundError: DidCommMessageRecord: No record found for given query '{\"associatedRecordId\":\"a9adb16d-b7b1-4587-9ef4-56373dc889fe\",\"messageName\":\"propose-presentation\",\"protocolName\":\"present-proof\",\"protocolMajorVersion\":\"1\"}'\n    at ?anon_0_ (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:185447:87)\n    at next (native)\n    at asyncGeneratorStep (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:28327:26)\n    at _next (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:28346:29)\n    at tryCallOne (/root/react-native/packages/react-native/ReactAndroid/hermes-engine/.cxx/Release/1i515cg5/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:53:16)\n    at anonymous (/root/react-native/packages/react-native/ReactAndroid/hermes-engine/.cxx/Release/1i515cg5/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:139:27)\n    at apply (native)\n    at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:34958:26)\n    at _callTimer (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:34837:17)\n    at _callReactNativeMicrotasksPass (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:34882:17)\n    at callReactNativeMicrotasks (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:35088:44)\n    at __callReactNativeMicrotasks (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:3256:46)\n    at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:3030:45)\n    at __guard (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:3229:15)\n    at flushedQueue (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:3029:21)"
  }
}
 ERROR  ERROR: Failed to process message {
  "error": {
    "name": "RecordNotFoundError",
    "message": "DidCommMessageRecord: No record found for given query '{\"associatedRecordId\":\"a9adb16d-b7b1-4587-9ef4-56373dc889fe\",\"messageName\":\"propose-presentation\",\"protocolName\":\"present-proof\",\"protocolMajorVersion\":\"1\"}'",
    "stack": "RecordNotFoundError: DidCommMessageRecord: No record found for given query '{\"associatedRecordId\":\"a9adb16d-b7b1-4587-9ef4-56373dc889fe\",\"messageName\":\"propose-presentation\",\"protocolName\":\"present-proof\",\"protocolMajorVersion\":\"1\"}'\n    at ?anon_0_ (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:185447:87)\n    at next (native)\n    at asyncGeneratorStep (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:28327:26)\n    at _next (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:28346:29)\n    at tryCallOne (/root/react-native/packages/react-native/ReactAndroid/hermes-engine/.cxx/Release/1i515cg5/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:53:16)\n    at anonymous (/root/react-native/packages/react-native/ReactAndroid/hermes-engine/.cxx/Release/1i515cg5/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:139:27)\n    at apply (native)\n    at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:34958:26)\n    at _callTimer (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:34837:17)\n    at _callReactNativeMicrotasksPass (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:34882:17)\n    at callReactNativeMicrotasks (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:35088:44)\n    at __callReactNativeMicrotasks (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:3256:46)\n    at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:3030:45)\n    at __guard (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:3229:15)\n    at flushedQueue (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=org.unicc.undigitalid&modulesOnly=false&runModule=true:3029:21)"
  }
}

Ah i meant as a possible solution to your problem that we could implement.

It's not working like that at the moment. Sorry for the confusion