-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: didcomm message handler should attempt to pass message to other handlers #1064
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very nice fix that also doesn't introduce a breaking change, which I would have expected for #944. Great work!
The test cases can be improved a little bit; please see my comments.
// shouldn't throw an error if other handlers fail | ||
let superHandled | ||
try { | ||
superHandled = await super.handle(message, context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I'm seeing here is that a message is parsed by this handler and it could be returned directly (which would also emit the validatedMessage event) but it can also be forwarded to other handlers in case they might be able to extract more value from it.
I like this idea a lot.
I wonder how we can incorporate it as the default way to handle all messages at some point.
Maybe message handlers can flag things as "good enough" so that the top-level handler knows not to throw an error at the end of the pipeline.
__tests__/shared/messageHandler.ts
Outdated
@@ -59,6 +59,7 @@ export default (testContext: { | |||
const allMessages = await agent.dataStoreORMGetMessages() | |||
const count = await agent.dataStoreORMGetMessagesCount() | |||
expect(allMessages.length).toEqual(count) | |||
expect(count).toEqual(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This creates some coupling between the tests and the order in which they are executed.
Perhaps the expectation should be that the count is not zero, if another test in this suite produces a message, but not give it a specific value in case other suites create messages of their own.
recipientDidUrl: sender.did, | ||
}) | ||
const messages = await agent.dataStoreORMGetMessagesCount({}) | ||
expect(messages).toEqual(2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testing message flow by count is prone to some weird test failures when multiple tests produce messages.
It would be better to use message IDs, or something else to check if they get processed correctly.
What issue is this PR fixing
fixes #944
What is being changed
DIDComm Message Handler should attempt to forward message to downstream handlers (but should not fail if none handle message)
Quality
Check all that apply:
yarn
,yarn build
,yarn test
,yarn test:browser
locally.