Skip to content
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

TypeError: setting 'error' on unknown CLIENT_ERROR bad command line format #26

Closed
cryptojcdenton opened this issue Nov 7, 2023 · 2 comments

Comments

@cryptojcdenton
Copy link

cryptojcdenton commented Nov 7, 2023

Hey, been using memcache-client since September in our open-source project, mostly everything has been great so thank you! I've encountered an unusual error that has occurred ~50 times on our servers over the last month, which crashes it due to an uncaught exception.

The stack trace goes like this:

TypeError: Cannot set properties of undefined (setting 'error')
/server/node_modules/memcache-client/dist/lib/connection.js in MemcacheConnection.receiveResult at line 188:32

                retrieve.results[pending.cmdTokens[1]] = {
                    tokens: pending.cmdTokens,
                    casUniq: pending.cmdTokens[4],
                    value: (_a = this.client) === null || _a === void 0 ? void 0 : _a._unpackValue(pending),
                };
            }
            catch (err) {
>>>Exception>>>>           retrieve.error = err;
            }
        }
        delete pending.data;
    }
    shutdown() {
        this._shutdown("Shutdown requested");
    }
/server/node_modules/memcache-parser/dist/lib/memcache-parser.js in MemcacheConnection._copyPending at line 157:26
/server/node_modules/memcache-parser/dist/lib/memcache-parser.js in MemcacheConnection._parseCmd at line 101:29
/server/node_modules/memcache-parser/dist/lib/memcache-parser.js in MemcacheConnection._processData at line 197:25
/server/node_modules/memcache-parser/dist/lib/memcache-parser.js in MemcacheConnection.onData at line 28:25
node:events in Socket.emit at line 514:28
node:domain in Socket.emit at line 488:12
node:internal/streams/readable in addChunk at line 376:12
node:internal/streams/readable in readableAddChunk at line 349:9
node:internal/streams/readable in Readable.push at line 286:10
node:internal/stream_base_commons in TCP.onStreamRead at line 190:23
CLIENT_ERROR bad command line format

It appears that retrieve can be null here: https://github.com/electrode-io/memcache/blob/master/packages/memcache-client/src/lib/connection.ts#L235, when corresponding with CLIENT_ERROR bad command line format. I don't know the specific command that causes this CLIENT_ERROR, but regardless, the memcache client crashes as a whole. Initially I increased maxConnections, as I thought it was some networking error.

Any ideas? Thanks!

Confirmed this error persists on 1.0.5.

@cryptojcdenton cryptojcdenton changed the title TypeError: Cannot set properties of undefined (setting 'error') on unknown CLIENT_ERROR bad command line format TypeError: setting 'error' on unknown CLIENT_ERROR bad command line format Nov 7, 2023
@jchip
Copy link
Member

jchip commented Nov 7, 2023

There was a command the server rejected with "bad command line format" error. That caused this handler to be invoked, which remove the command from queue

this.dequeueCommand()?.callback(error);

but then the server responded with more data that no longer has corresponding pending command.

If you can log from the server and find out the command that it rejected, then it'd help to figure out the issue.

@cryptojcdenton
Copy link
Author

Confirmed that this error is only appearing on high server load on 1.0.5, when we have a period of hundreds of requests hitting memcached per second. We had a recent spike of traffic and this error happened again after going away for a few days, crashing our server.

Will continue to debug, but it might be some form of concurrency issue since we share a memcache-client across all requests on the server!

@cryptojcdenton cryptojcdenton closed this as not planned Won't fix, can't repro, duplicate, stale Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants