rxjs-spy
rxjs-spy copied to clipboard
spy.show() doesn't filter out observables that run in sync
When using spy.show() from the console, observables that run synchronously are not filtered out of the list.
const asyncSub = new AsyncSubject();
asyncSub.next(null);
asyncSub.complete();
asyncSub.pipe(tag('nodelay.1')).subscribe();
asyncSub.pipe(tag('nodelay.2')).subscribe();
asyncSub
.pipe(
tag('delay.1'),
delay(1),
)
.subscribe();
asyncSub
.pipe(
tag('delay.2'),
delay(1),
)
.subscribe();
Why is that a problem? It states that they are complete. There will be more advanced querying capabilities in rxjs-devtools
, but this is not something that I intend to fix/change here.
Completed subscriptions will continue to be shown until the keptDuration
elapses.
I've actually got keptDuration set to zero in the demo. So they should have been wiped. As you can see, the other two tags were removed and they subscribed after the synchronous ones.
The issue is I'm combing through my site looking for any leaky subscriptions. Since the synchronous ones aren't removed, they become red-herrings. A work around is to add a delay(1) to the pipe, but that's altering code to fix a debug tool.
Also, I understand you're working on rxjs-devtools. I'm mostly logging this because it dogged me for two days and I'm hoping to spare others.
Try setting it to a small, non-zero number.
I'll add your synchronous AsyncSubject
scenario as a test in rxjs-devtools
is it's a problem there and the same solution applies to rxjs-spy
, I will fix it.
I added some sync tests for the graph flushing to rxjs-devtools
and they passed. I've added the same tests here and they too pass. I'm not going to look further into this because although the graphing implementation is pretty much unchanged, the snapshotting implementation in rxjs-devtools
is completely different.
FYI, I've added tests to rxjs-devtools
to determine whether or not snapshots for completed subscriptions are flushed correctly when snapshotting - based on the keptDuration
- and, yes, they appear to be.