File tree Expand file tree Collapse file tree 3 files changed +11
-15
lines changed Expand file tree Collapse file tree 3 files changed +11
-15
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @qwik.dev/core ' : patch
3
+ ---
4
+
5
+ fix: infinity serialization loop
Original file line number Diff line number Diff line change @@ -835,7 +835,7 @@ export const createSerializationContext = (
835
835
discoveredValues . push ( v ) ;
836
836
}
837
837
if ( obj . $effects$ ) {
838
- discoveredValues . push ( ... obj . $effects$ ) ;
838
+ discoveredValues . push ( obj . $effects$ ) ;
839
839
}
840
840
// WrappedSignal uses syncQrl which has no captured refs
841
841
if ( obj instanceof WrappedSignal ) {
@@ -847,6 +847,7 @@ export const createSerializationContext = (
847
847
discoveredValues . push ( obj . $hostElement$ ) ;
848
848
}
849
849
} else if ( obj instanceof ComputedSignal ) {
850
+ discoverEffectBackRefs ( obj [ _EFFECT_BACK_REF ] , discoveredValues ) ;
850
851
discoveredValues . push ( obj . $computeQrl$ ) ;
851
852
}
852
853
} else if ( obj instanceof Task ) {
@@ -944,18 +945,7 @@ const discoverEffectBackRefs = (
944
945
discoveredValues : unknown [ ]
945
946
) => {
946
947
if ( effectsBackRefs ) {
947
- // We need serialize effect subscriptions with back refs
948
- let hasBackRefs = false ;
949
- for ( const [ , effect ] of effectsBackRefs ) {
950
- const backRefs = effect [ EffectSubscriptionProp . BACK_REF ] ;
951
- if ( backRefs ) {
952
- hasBackRefs = true ;
953
- break ;
954
- }
955
- }
956
- if ( hasBackRefs ) {
957
- discoveredValues . push ( effectsBackRefs ) ;
958
- }
948
+ discoveredValues . push ( effectsBackRefs ) ;
959
949
}
960
950
} ;
961
951
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ import type { OnRenderFn } from '../shared/component.public';
32
32
import { _EFFECT_BACK_REF , NEEDS_COMPUTATION } from './flags' ;
33
33
import { QError , qError } from '../shared/error/error' ;
34
34
import { isDomContainer } from '../client/dom-container' ;
35
- import type { BackRef } from './signal-cleanup' ;
35
+ import { type BackRef } from './signal-cleanup' ;
36
36
import { getSubscriber } from './subscriber' ;
37
37
38
38
const DEBUG = false ;
@@ -328,7 +328,7 @@ export const triggerEffects = (
328
328
*
329
329
* The value is available synchronously, but the computation is done lazily.
330
330
*/
331
- export class ComputedSignal < T > extends Signal < T > {
331
+ export class ComputedSignal < T > extends Signal < T > implements BackRef {
332
332
/**
333
333
* The compute function is stored here.
334
334
*
@@ -340,6 +340,7 @@ export class ComputedSignal<T> extends Signal<T> {
340
340
// we need the old value to know if effects need running after computation
341
341
$invalid$ : boolean = true ;
342
342
$forceRunEffects$ : boolean = false ;
343
+ [ _EFFECT_BACK_REF ] : Map < EffectProperty | string , EffectSubscription > | null = null ;
343
344
344
345
constructor ( container : Container | null , fn : QRLInternal < ( ) => T > ) {
345
346
// The value is used for comparison when signals trigger, which can only happen
You can’t perform that action at this time.
0 commit comments