I think we are spawning a bunch of go blocks that are waiting for a signal from a promise chan to signal cancelling. We never close those channels and I suspect we are leaking those go blocks. (I’m actually tracking down an issue where we were spawning some futures for this purpose elsewhere and we were leaking those threads.) Is there a way i can get a hacky count of go blocks? Fine if it’s reaching in, just wanting to confirm hypothesis.
No
Go blocks don't really exist at runtime, they end up being either code running on an executor or callbacks waiting on a channel
Go blocks are not gc roots like a thread is
If a go block is not actively running the only thing that keeps it alive from a gc perspective is the reference to its callback the channel has. If the channel is not referenced it is gc'able regardless of if a go block is waiting on it or not
Dang. Was hoping there was some queue somewhere that I could count
But the construct (when (a/<! cancel-chan) …) in a thread will obviously not allow the thread to go away if the channel is never closed or gets a value. Will the go block hang around?
A go block waiting on a channel operation will get gc'ed if the channel does
A go block is just a callback when it is waiting on a channel operation