-
Notifications
You must be signed in to change notification settings - Fork 15
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
Documentation fails to mention required payload type with externally-published messages #76
Comments
Just to add to this... This comes down to the fact that internally-published messages are serialized and de-serialized using the same serializer, which means that in reality, whatever format they serialize it to is also the format they expect to deserialize later on. For example, providing JSON works fine because the default serializer ( JSON.stringify('Hello world')
// '"Hello world"'
JSON.parse(JSON.stringify('Hello world'))
// 'Hello world' Following that method, supplying the payload of I think it's still worth adding something to documentation that emphasizes how externally-published messages are deserialised to prevent people ending up in this pitfall. But more importantly, the current error message is very misleading and adding some better visibility into messages which could not be serialised should be the focus here. I am happy to open a PR if this is a change you would find helpful. |
@marceliwac Could you create a minimal reproduction example code in Python so that we can investigate the issue? |
Here's the repro example: https://github.com/moleculerjs/moleculer-channels/blob/issue-76/examples/external-message/index.js @marceliwac did a good job looking for a source of the problem. Overall, channels cannot parse the payload if the serializer is not the same |
@icebob , I should (hopefully) be able to go one better with the PR above. Understandably, the added tests only look at the logger usage, so their usefulness might be limited once this issue is resolved. Until then, they should hopefully help with debugging / help highlight the issue.
To add to this, it depends on how the serializers handle data. For example,
|
I think it's not a common use-case using different serialized payloads for the same topic. @marceliwac could you tell us more about your use-case? |
@icebob I was actually using an entirely separate Python program and used moleculer-channels as interoperability layer, which is how I ran into the serialiser problems. While I don't expect people to be mixing serialisers (or use moleculer-channels in a similar workflow) too frequently, I think that it could be more robust in how it handles different serialisers, or at least provide clearer error messages. |
@icebob Is there anything that I could do to resolve this issue? Would you like me to create a PR that displays a dedicated error message if the deserialisation fails (rather than letting the transporter deliver it multiple times and throwing the redelivery error message)? |
Prerequisites
Please answer the following questions for yourself before submitting an issue.
Current Behavior
Publishing messages from within the moleculer actions/methods works fine. For example:
Publishing messages with objects in payload ✅
Publishing messages with strings in payload ✅
This behaviour changes when publishing messages externally (e.g. using NATS CLI, or from a python script connected to the same NATS instance).
Publishing messages with objects in payload ✅
Publishing messages with strings in payload 🚫
This produces the following error:
Needless to say, it took me a while to pinpoint this issue to the payload, rather than some problems with invalid delivery of messages. This plugin seems to be rejecting the messages / nack'ing them without any information that the messages were received in the first place.
Expected Behavior
Publishing string-based messages (or other types for that matter) works fine. Alternatively, there should be some mention in the documentation on the limitations of how this integrates with externally-published messages.
The text was updated successfully, but these errors were encountered: