File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
packages/seroval/src/binary Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ export interface DeserializerContext {
6666 refs : Map < number , { value : unknown } > ;
6767 plugins ?: Plugin < any , any > [ ] ;
6868 root : PromiseConstructorResolver ;
69+ rootFound : boolean ;
6970 done : boolean ;
7071 buffer : Uint8Array ;
7172 marker : Map < number , SerovalBinaryType > ;
@@ -81,6 +82,7 @@ export function createDeserializerContext(
8182 done : false ,
8283 buffer : new Uint8Array ( ) ,
8384 root : PROMISE_CONSTRUCTOR ( ) ,
85+ rootFound : false ,
8486 read : options . read ,
8587 onError : options . onError ,
8688 refs : options . refs ,
@@ -627,6 +629,7 @@ async function deserializePlugin(ctx: DeserializerContext) {
627629
628630async function deserializeRoot ( ctx : DeserializerContext ) {
629631 const reference = await deserializeRef ( ctx , SerovalBinaryType . Root ) ;
632+ ctx . rootFound = true ;
630633 ctx . root . s ( reference ) ;
631634}
632635
@@ -782,7 +785,10 @@ async function drain(ctx: DeserializerContext) {
782785 while ( true ) {
783786 if ( ctx . buffer . length === 0 ) {
784787 if ( ctx . done ) {
785- return ;
788+ if ( ctx . rootFound ) {
789+ return ;
790+ }
791+ throw new SerovalMalformedBinarySourceError ( ) ;
786792 }
787793 await readChunk ( ctx ) ;
788794 } else {
You can’t perform that action at this time.
0 commit comments