You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In initDirectReplyQueue() (connection.js) it's trying to parse what it expects to be JSON content inside the Buffer.
JSON.parse(msg.content.toString()),
If the Buffer is empty (i.e. the RPC handler returned a null/void/undefined) then it's trying to parse an empty string. This throws an error.
(node:2736) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at channel.consume.noAck (/usr/local/src/packages/wilco-svc-omniapi/node_modules/@golevelup/nestjs-rabbitmq/lib/amqp/connection.js:95:67)
at ConfirmChannel.BaseChannel.dispatchMessage (/usr/local/src/packages/wilco-svc-omniapi/node_modules/amqplib/lib/channel.js:484:12)
at ConfirmChannel.BaseChannel.handleDelivery (/usr/local/src/packages/wilco-svc-omniapi/node_modules/amqplib/lib/channel.js:493:15)
at ConfirmChannel.emit (events.js:314:20)
at /usr/local/src/packages/wilco-svc-omniapi/node_modules/amqplib/lib/channel.js:279:10
at ConfirmChannel.headers (/usr/local/src/packages/wilco-svc-omniapi/node_modules/amqplib/lib/channel.js:306:9)
at ConfirmChannel.C.acceptMessageFrame (/usr/local/src/packages/wilco-svc-omniapi/node_modules/amqplib/lib/channel.js:247:31)
at ConfirmChannel.C.accept (/usr/local/src/packages/wilco-svc-omniapi/node_modules/amqplib/lib/channel.js:400:17)
at Connection.mainAccept [as accept] (/usr/local/src/packages/wilco-svc-omniapi/node_modules/amqplib/lib/connection.js:64:33)
at Socket.go (/usr/local/src/packages/wilco-svc-omniapi/node_modules/amqplib/lib/connection.js:478:48)
at Socket.emit (events.js:314:20)
at emitReadable_ (_stream_readable.js:557:12)
at processTicksAndRejections (internal/process/task_queues.js:83:21)
I was going to propose handling it the same way it's currently being handled in handleMessage() with a try/catch, this seems robust but would also resolve non-JSON content as undefined (not just null values) which may be undesirable.
Instead I propose more specifically handling an empty Buffer to prevent JSON parse from throwing the error. Will submit a PR.
The text was updated successfully, but these errors were encountered:
ChrisBates
added a commit
to ChrisBates/nestjs
that referenced
this issue
Jul 2, 2021
In
initDirectReplyQueue()
(connection.js
) it's trying to parse what it expects to be JSON content inside the Buffer.If the Buffer is empty (i.e. the RPC handler returned a null/void/undefined) then it's trying to parse an empty string. This throws an error.
I was going to propose handling it the same way it's currently being handled in
handleMessage()
with a try/catch, this seems robust but would also resolve non-JSON content asundefined
(not just null values) which may be undesirable.Instead I propose more specifically handling an empty Buffer to prevent JSON parse from throwing the error. Will submit a PR.
The text was updated successfully, but these errors were encountered: