Code RoomSubscription persists after dismiss
HardPrep Room Coding #4211

Subscription persists after dismiss

Vibe & agenticAlgorithms & data structuresSenior–Staff~19 min

An AI wrote this Swift Combine subscription to update a balance label from a shared publisher. It works, but after the user navigates away from and back to this screen several times, you notice old screens still receiving updates, and the network layer reports duplicate in-flight requests multiplying. What's wrong and how would you fix it?

Implement
audit_subscription_leak(navigation_events: list[str], store_cancellable: bool, weak_self: bool) → list[int]
Examples
in[["open","emit","close","open","emit","close","open","emit"],false,false]out[6,2]
in[["open","emit","close","open","emit","close","open","emit"],true,false]out[3,0]
in[["open","emit","close","open","emit","close","open","emit"],false,true]out[6,0]
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.

0:00 of about 19 min

Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.

Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.