mirror of
https://github.com/block/buzz.git
synced 2026-11-09 10:51:42 +00:00
fix(desktop): bound start marks for traces that never record
Blind-review round 3 (Sonnet) finding: beginChannelSwitchTrace marked unconditionally but only record() cleared, so every abandoned/dropped trace (forum visits, route exits, hidden-window and frame-starved drops) leaked a permanent buzz:channel-switch:start entry. Clearing the previous start mark at begin bounds the buffer to one entry no matter how the prior trace ended. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Max Lampert <maxwell@squareup.com>
This commit is contained in:
@@ -248,6 +248,27 @@ test("an undisturbed settle records exactly one measure", async () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("abandoned switches never accumulate start marks", async () => {
|
||||
await withSettleHarness(async ({ abandon, begin }) => {
|
||||
const { CHANNEL_SWITCH_START_MARK } = await import(
|
||||
"./channelSwitchPerf.ts"
|
||||
);
|
||||
performance.clearMarks?.(CHANNEL_SWITCH_START_MARK);
|
||||
// Traces that die without recording (forum visits, route exits, drops)
|
||||
// never reach record()'s buffer clearing — begin() must bound the
|
||||
// buffer itself or weeks-long sessions accumulate a mark per abandon.
|
||||
for (const channelId of ["aaaa", "bbbb", "cccc", "dddd"]) {
|
||||
begin(channelId);
|
||||
abandon(channelId);
|
||||
}
|
||||
assert.equal(
|
||||
performance.getEntriesByName(CHANNEL_SWITCH_START_MARK).length,
|
||||
1,
|
||||
);
|
||||
performance.clearMarks?.(CHANNEL_SWITCH_START_MARK);
|
||||
});
|
||||
});
|
||||
|
||||
test("a settle in a hidden window drops the trace instead of recording", async () => {
|
||||
await withSettleHarness(
|
||||
async ({ begin, settle, flush, measures }) => {
|
||||
|
||||
@@ -201,6 +201,12 @@ export function beginChannelSwitchTrace(channelId: string): void {
|
||||
windowFetch: null,
|
||||
membersFetch: null,
|
||||
};
|
||||
// Clear the previous start mark here, not only in record(): traces that
|
||||
// die without recording (forum visits, route exits, drops) never reach
|
||||
// record()'s buffer clearing, and weeks-long sessions would accumulate a
|
||||
// stray mark per abandon. Clearing at begin bounds the buffer to one
|
||||
// start mark no matter how the previous trace ended.
|
||||
performance.clearMarks(CHANNEL_SWITCH_START_MARK);
|
||||
performance.mark(CHANNEL_SWITCH_START_MARK, { detail: { channelId } });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user