diff --git a/lib/command.ts b/lib/command.ts index 9819abd1..9bfbe1f8 100644 --- a/lib/command.ts +++ b/lib/command.ts @@ -220,7 +220,7 @@ export default class Command { } let result - let commandStr = '*' + (this.args.length + 1) + '\r\n$' + this.name.length + '\r\n' + this.name + '\r\n' + let commandStr = '*' + (this.args.length + 1) + '\r\n$' + Buffer.byteLength(this.name) + '\r\n' + this.name + '\r\n' if (bufferMode) { const buffers = new MixedBuffers(); buffers.push(commandStr); diff --git a/test/functional/send_command.js b/test/functional/send_command.js index 6b84dc52..e100cf63 100644 --- a/test/functional/send_command.js +++ b/test/functional/send_command.js @@ -207,4 +207,17 @@ describe('send command', function () { }); }); }); + + it('throws for invalid command', async () => { + const redis = new Redis() + const invalidCommand = 'áéűáű' + let err + try { + await redis.call(invalidCommand, []) + } catch(e) { + err = e.message + } + expect(err).to.contain('unknown command') + expect(err).to.contain(invalidCommand) + }) });