File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ import { inclusionUserCallbacks } from "./inclusion_user_callbacks.js";
47
47
import { MessageHandler } from "./message_handler.js" ;
48
48
import { ConfigManagerMessageHandler } from "./config_manager/message_handler.js" ;
49
49
import { ZnifferMessageHandler } from "./zniffer/message_handler.js" ;
50
+ import { stringifyReplacer } from "../util/stringify.js" ;
50
51
51
52
function getVersionData ( driver : Driver ) : {
52
53
homeId : number | undefined ;
@@ -318,7 +319,7 @@ export class Client {
318
319
}
319
320
320
321
sendData ( data : OutgoingMessages . OutgoingMessage , compress = false ) {
321
- this . socket . send ( JSON . stringify ( data ) , { compress } ) ;
322
+ this . socket . send ( JSON . stringify ( data , stringifyReplacer ) , { compress } ) ;
322
323
}
323
324
324
325
checkAlive ( ) {
Original file line number Diff line number Diff line change
1
+ import { isUint8Array } from "node:util/types" ;
2
+
3
+ export function stringifyReplacer ( key : string , value : any ) : any {
4
+ // Ensure that Uint8Arrays are serialized as if they were Buffers
5
+ // to keep the API backwards compatible
6
+ if ( isUint8Array ( value ) ) {
7
+ return Buffer . from ( value ) . toJSON ( ) ;
8
+ }
9
+ return value ;
10
+ }
You can’t perform that action at this time.
0 commit comments