fix: use correct subscription key in publishAsync#106
fix: use correct subscription key in publishAsync#106jdesrosiers merged 2 commits intohyperjump-io:mainfrom
Conversation
Signed-off-by: justin212407 <charlesjustin2124@gmail.com>
|
hi @justin212407 here subscribedMessage is equal to the message as you can see in the above line, so I don't think its a bug. |
|
@animeshsahoo1 please take a closer look the only difference is that, while |
|
oh yeah true didnt see the 2nd condition |
jdesrosiers
left a comment
There was a problem hiding this comment.
As I mentioned in the issue, please remove the unused code instead. Also, please wait for discussion before creating a PR. The obvious solution may not always be the right solution, so it's worth discussing first.
Apologies, will definitely ensure that a proper discussion is held regarding an issue before i open a PR over from the next time. |
Signed-off-by: justin212407 <charlesjustin2124@gmail.com>
jdesrosiers
left a comment
There was a problem hiding this comment.
Good enough. Thanks.
Summary
publishAsyncinpubsub.jscontained bug where subscriber callbacks were being looked up using the published message key instead of the matchedsubscribedMessagekey.Both
publishandpublishAsynciterate over all registered subscription keys and match them against the incoming message using startsWith to support topic prefixes (e.g. a subscriber on "validate" catching "validate.metaValidate"). However, publishAsync incorrectly used subscriptions[message] when invoking the callback instead of subscriptions[subscribedMessage], meaning when the two keys diverged the lookup would target the wrong subscription map returning undefined and throwing a TypeError at runtime.Result
Wildcard subscriptions now work properly with async events without crashing. The async and sync pub/sub implementations now behave the same way.
Fixes - #105