Skip to content
This repository has been archived by the owner on Jul 23, 2023. It is now read-only.

Commit

Permalink
bugs fixed: when client send circular json data, JSON.stringify lead …
Browse files Browse the repository at this point in the history
…to unack queue
  • Loading branch information
Johnny Huang committed Dec 26, 2018
1 parent 7469983 commit 01b1745
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/amqp.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,17 @@ async function onRPC ( connection, qName, callback) {
return callback(
data,
out => {
let obj;
try {
obj = JSON.stringify( out);
} catch( e) {
obj = {
code: 500,
msg: 'error_occur_when_data_stringify'
};
}
ch.sendToQueue( msg.properties.replyTo,
Buffer.from( JSON.stringify( out)),
Buffer.from( obj),
{ correlationId: msg.properties.correlationId });
ch.ack( msg);
}
Expand Down

0 comments on commit 01b1745

Please sign in to comment.