Skip to content

Commit caaf84a

Browse files
Karthikeya1500nickva
authored andcommitted
Fix ReferenceError in QuickJS dispatch
If an unrecognized command is processed by globalThis.dispatch, the error handler attempts to reference cmdkey without it being defined. This throws a ReferenceError instead of generating the intended CouchDB fatal error array. This commit assigns cmd.shift() to a const variable cmdkey before evaluating the switch statement.
1 parent fc236b7 commit caaf84a

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

share/server/dispatch-quickjs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ globalThis.dispatch = function(line) {
154154
const cmd = JSON.parse(line);
155155
State.line_length = line.length;
156156
try {
157-
switch (cmd.shift()) {
157+
const cmdkey = cmd.shift();
158+
switch (cmdkey) {
158159
case "ddoc":
159160
DDoc.ddoc.apply(null, cmd);
160161
break;

0 commit comments

Comments
 (0)