File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
packages/protocol/src/common Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ export type IEncodingOptionsCallback = IEncodingOptions | ((err: NodeJS.ErrnoExc
3131 */
3232export const stringify = ( arg : any ) : string => { // tslint:disable-line no-any
3333 if ( arg instanceof Error ) {
34+ // Errors don't stringify at all. They just become "{}".
3435 return JSON . stringify ( {
3536 type : "Error" ,
3637 data : {
@@ -39,6 +40,15 @@ export const stringify = (arg: any): string => { // tslint:disable-line no-any
3940 stack : arg . stack ,
4041 } ,
4142 } ) ;
43+ } else if ( arg instanceof Uint8Array ) {
44+ // With stringify, these get turned into objects with each index becoming a
45+ // key for some reason. Then trying to do something like write that data
46+ // results in [object Object] being written. Stringify them like a Buffer
47+ // instead.
48+ return JSON . stringify ( {
49+ type : "Buffer" ,
50+ data : Array . from ( arg ) ,
51+ } ) ;
4252 }
4353
4454 return JSON . stringify ( arg ) ;
You can’t perform that action at this time.
0 commit comments