fix(queue-events-producer): serialize object payloads as JSON - #4108
Open
mohanrajvenkatesan23-04 wants to merge 1 commit into
Open
Conversation
QueueEventsProducer.publishEvent pushed nested object values straight into XADD args, leaving Redis to coerce them via toString() — which yields "[object Object]" for plain objects. The payload was therefore unrecoverable on the consumer side. Now non-primitive values are JSON.stringified before being pushed onto the args array, mirroring the pattern already used for the built-in `progress` and `completed` events. Primitives are passed through unchanged so existing custom-event publishers see no behavioural change. Consumers of object-typed custom events can JSON.parse the value on receive (the consumer side intentionally stays opt-in to avoid mis-parsing strings that happen to look like JSON). Fixes taskforcesh#2984
manast
requested review from
Copilot and
roggervalf
and removed request for
Copilot
July 15, 2026 18:09
Contributor
|
@copilot resolve the merge conflicts in this pull request |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port Impact Checklist
Why
Fixes #2984.
QueueEventsProducer.publishEventpushed each value of the payload straight onto the XADD args array. Redis then coerces every arg to a string via.toString(). For plain objects that yields"[object Object]", so a payload like{ eventName: 'name', nested: { object: 'hello' } }arrived on the consumer side as{ eventName: 'name', nested: '[object Object]' }— the original structure was unrecoverable.The user reported the issue on
src/classes/queue-events-producer.tsline 43 and noted that JSON serialization is the natural fix.How
src/classes/queue-events-producer.ts: when a value is a non-null object (plain object, array, class instance),JSON.stringifyit before pushing onto the args array. Primitive values (strings, numbers, booleans) are left alone so existing publishers that already pass primitives observe no change.progress/completedevents: their payloads round-trip throughJSON.stringifyon the producer side andJSON.parseon the consumer side (src/classes/queue-events.ts).JSON.parsethemselves on the field they expect.Additional Notes (Optional)
tests/events.test.ts(when publishing custom events › serializes nested object payloads as JSON) publishes a{ object: 'hello' }payload and asserts the receiver gets a JSON-string that parses back to the original object. Before the fix the test fails with'[object Object]'.publishEvent<T>is unchanged.