Skip to content

Commit c47b4a9

Browse files
committed
fix(server): Fix incorrect native result wrapper processing via webSockets
1 parent d805b4b commit c47b4a9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/cubejs-server/src/websocket-server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ export class WebSocketServer {
4545
const resMsg = new TextDecoder().decode(await message.message.getFinalResult());
4646
message.message = '~XXXXX~';
4747
messageStr = JSON.stringify(message);
48-
messageStr = messageStr.replace('"~XXXXX~"', resMsg);
48+
// resMsg may include any symbols and String.replace sometimes might treat them as a special/command symbols,
49+
// to prevent this implicit unexpected changes we use replacer function, which returns what we want.
50+
messageStr = messageStr.replace('"~XXXXX~"', () => resMsg);
4951
} else {
5052
messageStr = JSON.stringify(message);
5153
}

0 commit comments

Comments
 (0)