nsqjs
nsqjs copied to clipboard
Cannot publish object to deferPublish
const account = { name: "Gijo Varghese"};
writer.publish('account-updated', account); // works fine
writer.deferPublish('account-updated', account, 1000); // ERROR - Expect an array of messages to produceMessages
writer.deferPublish('account-updated', [account], 1000); // ERROR - The "list[2]" argument must be one of type Array, Buffer, or Uint8Array. Received type object
writer.deferPublish('account-updated', [JSON.stringify(account)], 1000); // works!
From the docs:
deferPublish(topic, msg, timeMs, [callback]) topic is a string. msg is either a string, a Buffer, JSON serializable object. timeMs is the delay by which the message should be delivered. callback takes a single error argument.
Is it a bug?