posit-dev / positron

Positron, a next-generation data science IDE
Other
2.46k stars 73 forks source link

ark: Behaviour with redundant `open_comm` messages #2001

Open lionel- opened 8 months ago

lionel- commented 8 months ago

When this happens, positron functionality is limited. We no longer receive set-console-width events for instance.

[R] 2024-01-03T15:26:16.633372000Z [ark-unknown] ERROR crates/ark/src/frontend/frontend.rs:66: Error receiving Positron event; closing event listener: RecvError

A RecvError indicates the channel is closed, which can only occur if all senders have been dropped, but that doesn't appear to be the case. Puzzling.

This unexpected channel closing is what caused the infinite logs issue that was fixed in https://github.com/posit-dev/amalthea/pull/176

lionel- commented 8 months ago

This happens when the frontend comm is started twice in a row. Which happens when the heartbeat setting of the jupyter adapter is set to 0. In that case, a timeout bug causes the Jupyter runtime to briefly enter the Offline state. When we switch back to Ready, some initialisation code recreates of the frontend and help comms.

I think we need a few fixes here:

I lean towards making createClient() idempotent in both ark and jupyter-adapter and reuse existing clients if called multiple times. To actually recreate a client, you'd need to call removeClient() first. WDYT @jmcphers?