File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed
packages/qwik/src/core/shared/serdes Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -958,6 +958,21 @@ describe('shared-serialization', () => {
958
958
(42 chars)"
959
959
` ) ;
960
960
} ) ;
961
+ it ( 'should dedupe identical root qrls' , async ( ) => {
962
+ const fn = ( ) => 'hi' ;
963
+ const a = { } ;
964
+ const qrl1 = inlinedQrl ( fn , 'dump_qrl' , [ a ] ) ;
965
+ const qrl2 = inlinedQrl ( fn , 'dump_qrl' , [ a ] ) ;
966
+ expect ( qrl1 ) . not . toBe ( qrl2 ) ;
967
+ const objs = await serialize ( qrl1 , qrl2 ) ;
968
+ expect ( _dumpState ( objs ) ) . toMatchInlineSnapshot ( `
969
+ "
970
+ 0 QRL "mock-chunk#dump_qrl[2]"
971
+ 1 RootRef 0
972
+ 2 Object []
973
+ (38 chars)"
974
+ ` ) ;
975
+ } ) ;
961
976
} ) ;
962
977
963
978
describe ( 'Serialization Weak Ref' , ( ) => {
Original file line number Diff line number Diff line change @@ -170,11 +170,9 @@ export async function serialize(serializationContext: SerializationContext): Pro
170
170
const existing = qrlMap . get ( qrl ) ;
171
171
if ( existing ) {
172
172
// We encountered the same QRL again, make it a root
173
- $addRoot$ ( existing ) ;
174
- // We need to force because we might be adding the same root again
175
- if ( outputAsRootRef ( existing , 0 ) ) {
176
- return ;
177
- }
173
+ const ref = $addRoot$ ( existing ) ;
174
+ output ( TypeIds . RootRef , ref ) ;
175
+ return ;
178
176
} else {
179
177
qrlMap . set ( qrl , value ) ;
180
178
}
You can’t perform that action at this time.
0 commit comments