Skip to content

Commit b347c9d

Browse files
committed
refactor: wip
1 parent e227c8f commit b347c9d

File tree

2 files changed

+0
-46
lines changed

2 files changed

+0
-46
lines changed

packages/utils/src/lib/performance-observer.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,6 @@ export class PerformanceObserverSink<T> implements Observer, Buffered {
223223
}
224224

225225
this.#observer = new PerformanceObserver(list => {
226-
if (this.#sink.isClosed()) {
227-
this.#queue.length = 0;
228-
return;
229-
}
230-
231226
list.getEntries().forEach(entry => {
232227
if (OBSERVED_TYPE_SET.has(entry.entryType as ObservedEntryType)) {
233228
const items = this.encode(entry);

packages/utils/src/lib/performance-observer.unit.test.ts

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -622,47 +622,6 @@ describe('PerformanceObserverSink', () => {
622622
observer.unsubscribe();
623623
});
624624

625-
it('observer callback clears queue when sink closes during observation', () => {
626-
const observer = new PerformanceObserverSink({
627-
sink,
628-
encodePerfEntry,
629-
flushThreshold: 10, // High threshold to prevent automatic flushing
630-
});
631-
632-
observer.subscribe();
633-
634-
const mockObserver = MockPerformanceObserver.lastInstance();
635-
mockObserver?.emit([
636-
{
637-
name: 'test-entry-1',
638-
entryType: 'mark',
639-
startTime: 0,
640-
duration: 0,
641-
},
642-
]);
643-
644-
// Verify entry is queued
645-
expect(observer.getStats().queued).toBe(1);
646-
647-
// Close the sink while observer is still active
648-
sink.close();
649-
650-
// Emit another entry - the callback should detect closed sink and clear queue
651-
mockObserver?.emit([
652-
{
653-
name: 'test-entry-2',
654-
entryType: 'mark',
655-
startTime: 0,
656-
duration: 0,
657-
},
658-
]);
659-
660-
// Queue should be cleared due to closed sink in callback
661-
expect(observer.getStats().queued).toBe(0);
662-
663-
observer.unsubscribe();
664-
});
665-
666625
it('clears queue without writing when sink is closed during flush', () => {
667626
const observer = new PerformanceObserverSink({
668627
sink,

0 commit comments

Comments
 (0)