-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Incorrect setReturnBuffers when parsing PubSub 'message' response #1870
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
Comments
Commenting out I expect that will cause other problems since that change was made for a reason (which was unfortunately not described in the commit message). |
@aleiby I haven't debugged it yet, but I'm working on a new RESP parser, which (hopefully) will solve this problem as well. Will keep you posted. |
This issue is affecting our production as well, when should we expect a fix for this? |
@aleiby @manikyafc I think that the changes in #1899 solve this problem, do you have a reproduction of the issue? |
It happens fairly reliably in my codebase, but I was unable to distill it down into an easily sharable repro unfortunately. You need to construct a scenario where |
Hi, thanks for the potential fix. I don't have steps to reproduce the issue, just that we can observe this issue in server logs/during testing on local from time to time, I can try cloning to local and test if the issue shows up again |
Same deal for us. This is the stack trace:
Happens every time the code is executed. Also a production service. Currently blocked on this. |
Hi @leibale : I tried your branch as in: Our package.json:
and we get:
Is this not supposed to be a drop-in fix? |
@binarymist first of all, thanks for helping! :) Regarding the error, you can't git clone --single-branch --branch parser https://github.com/leibale/node-redis
cd node-redis
npm install -ws
npm run build-all then use |
Same here. Waiting the release that fixes this bug. |
Thanks @leibale. Not sure we're helping ;-), just need to get this fixed before we can release/publish. Our project that consumes the redis NPM package that is experiencing this issue is run in a container. I've added the following to the Dockerfile:
package.json reverted to:
Still get the |
@leibale: Which Pull Request is supposed to fix this, #1899 or the newer #2016 from @jhiesey? |
@binarymist I can't speak for the maintainers, but my PR is a quick fix for the immediate issue. #1899 is a rewrite of the parser and is a better long term solution but I suspect it's not quite ready. The workaround I'm currently using is to install patch-package and add this patch file, which is equivalent to the change in #2016 at diff --git a/node_modules/@node-redis/client/dist/lib/client/commands-queue.js b/node_modules/@node-redis/client/dist/lib/client/commands-queue.js
index 8d22295..d3e7807 100644
--- a/node_modules/@node-redis/client/dist/lib/client/commands-queue.js
+++ b/node_modules/@node-redis/client/dist/lib/client/commands-queue.js
@@ -279,7 +279,8 @@ _a = RedisCommandsQueue, _RedisCommandsQueue_maxLength = new WeakMap(), _RedisCo
}, _RedisCommandsQueue_setReturnBuffers = function _RedisCommandsQueue_setReturnBuffers() {
var _b, _c;
__classPrivateFieldGet(this, _RedisCommandsQueue_parser, "f").setReturnBuffers(!!((_b = __classPrivateFieldGet(this, _RedisCommandsQueue_waitingForReply, "f").head) === null || _b === void 0 ? void 0 : _b.value.returnBuffers) ||
- !!((_c = __classPrivateFieldGet(this, _RedisCommandsQueue_pubSubState, "f")) === null || _c === void 0 ? void 0 : _c.subscribed));
+ !!((_c = __classPrivateFieldGet(this, _RedisCommandsQueue_pubSubState, "f")) === null || _c === void 0 ? void 0 : _c.subscribed) ||
+ !!((_c = __classPrivateFieldGet(this, _RedisCommandsQueue_pubSubState, "f")) === null || _c === void 0 ? void 0 : _c.subscribing));
}, _RedisCommandsQueue_shiftWaitingForReply = function _RedisCommandsQueue_shiftWaitingForReply() {
if (!__classPrivateFieldGet(this, _RedisCommandsQueue_waitingForReply, "f").length) {
throw new Error('Got an unexpected reply from Redis');
|
That's a useful tool @jhiesey, although there seems to be another issue:
Which I'm now getting earler at: https://github.com/purpleteam-labs/purpleteam-orchestrator/blob/0f77b4a9d31844629f323891b5b9ce7f9e7ce98e/src/api/orchestration/subscribers/testerWatcher.js#L72 This doesn't appear to be related to your patch @jhiesey, as when I I don't think I mssed anything in https://github.com/redis/node-redis/blob/HEAD/docs/v3-to-v4.md |
Ok, the next problem was casing of Something is still broken though, I'm just not getting any errors now. |
@binarymist change it to |
Yip, got that one thanks. Something is still broken though, I'm going to have to spend more time debugging. |
I see this issue as closed but I am getting this error for pub sub messages randomly every now and then. "The "otherBuffer" argument must be an instance of Buffer or Uint8Array." I've read through this closed issue but it's not clear to me How to resolve this? Can someone please point it out? Thank you! |
@leibale Could you please explain why the issue was closed? |
Also, could anybody explain how such an exception could be caught? Currently, it's just crashing my server completely. |
@digitalml @mifopen the issue is closed because the fix was merged to master. Unfortunately there hasn't been a release published that includes the fix; hopefully there will be one soon. Perhaps @leibale could comment on when. You can use my workaround in #1870 (comment) for the time being |
@leibale when do you plan to release the next version with this fix? |
A new version with @jhiesey fix will be released tomorrow. Sorry it took so much time. |
@alexzaporozhets @NormandoHall @digitalml @jhiesey @mifopen @binarymist |
Since upgrading my redis server to 6.2.6 and redis client to 4.0.2 (from 4.0.1) I've been occasionally seeing the following crash:
TypeError [ERR_INVALID_ARG_TYPE]: The "otherBuffer" argument must be an instance of Buffer or Uint8Array. Received type string ('message')
I've tracked this down to
parser.optionReturnBuffers
being set tofalse
when it should betrue
causing the 'message' string to be returned as a string rather than a Buffer.commands-queue.ts expects this to be
a Buffer, and Buffer.equals throws the above NodeError.
This response comes in through parseResponse which calls
this.#setReturnBuffers()
. I haven't been able to track down why this works correctly most of the time, but occasionally winds up settingparser.optionReturnBuffers
tofalse
and blowing up. Hopefully someone more familiar with the code can spot what's going on.Environment:
The text was updated successfully, but these errors were encountered: