File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
packages/cubejs-server/src Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,21 @@ export class WebSocketServer {
3636 throw new Error ( `Socket for ${ connectionId } is not found found` ) ;
3737 }
3838
39- connectionIdToSocket [ connectionId ] . send ( JSON . stringify ( message ) ) ;
39+ let messageStr : string ;
40+
41+ if ( message . message instanceof ArrayBuffer ) {
42+ // In case we already have a JSON-serialized query result, we don't want to parse/stringify
43+ // it again - it's too expensive, instead we serialize the rest of the message and then
44+ // inject query result json into message.
45+ const resMsg = new TextDecoder ( ) . decode ( message . message ) ;
46+ message . message = "~XXXXX~" ;
47+ messageStr = JSON . stringify ( message ) ;
48+ messageStr = messageStr . replace ( `"~XXXXX~"` , resMsg ) ;
49+ } else {
50+ messageStr = JSON . stringify ( message ) ;
51+ }
52+
53+ connectionIdToSocket [ connectionId ] . send ( messageStr ) ;
4054 } ) ;
4155
4256 this . wsServer . on ( 'connection' , ( ws ) => {
You can’t perform that action at this time.
0 commit comments