`intercept/1` in phoenix channel will delay `handle_out`?

I have lib/my_app as generated by Phoenix, and then I also created my own lib/quickbooks_sync_cache OTP app to manage Quickbooks syncing.

I spawn QuickbooksSyncCache.SycnWorker genserver processes to sync some data from my main app to Quickbooks. During the worker processes’s lifespan, it’ll map over entities and post them to Quickbooks, once the post is finished, it’ll fire an Endpoint.broadcast!("companies:1", "qb_sync_progress", newly_synced_item) to let a channel in my main app know that an item was synced.

Once the worker process is done its job, it’s supervisor will terminate it (this is important).

The weird thing is that if I intercept["qb_sync_progress"] and provide my own custom handle_out function, the handle_out will not receive any messages until the worker process who broadcasted them has been terminated.

However, if I dont intercept the handle_out, everything works exactly fine and on time.

I have no idea what’s happening here… Could someone more experienced than I elaborate for me? I’d much appreciate the help :slight_smile:

The two shouldn’t be related (intercept and a remote process terminating). What work are you doing in handle_out? Is it possible you’re calling back into the system and blocking on something that is freed with process terminates? If you could share your code both for you gen server and for your channel we could say more.

1 Like