Skip to content

fix: don't init Iroh on channel leave#7210

Merged
link2xt merged 7 commits intomainfrom
webxdc-dont-init-realtime-on-leave
Sep 20, 2025
Merged

fix: don't init Iroh on channel leave#7210
link2xt merged 7 commits intomainfrom
webxdc-dont-init-realtime-on-leave

Conversation

@WofWca
Copy link
Copy Markdown
Collaborator

@WofWca WofWca commented Sep 19, 2025

Some Delta Chat clients (Desktop, for example)
do leave_webxdc_realtime
regardless of whether we've ever joined a realtime channel
in the first place. Such as when closing a WebXDC window.
This might result in unexpected and suspicious firewall warnings.

Related:

TODO:

  • Please dobule-check that this does not have
    negative side effects, e.g. that we actually don't need
    to initialize Iroh on leave_webxdc_realtime
    and, say, delete the topic from the database.

Some Delta Chat clients (Desktop, for example)
do `leave_webxdc_realtime`
regardless of whether we've ever joined a realtime channel
in the first place. Such as when closing a WebXDC window.
This might result in unexpected and suspicious firewall warnings.

Related:
- #6443.
- deltachat/deltachat-desktop#3218.
@WofWca WofWca added webxdc bug Something is not working labels Sep 19, 2025
pub async fn leave_webxdc_realtime(ctx: &Context, msg_id: MsgId) -> Result<()> {
if !ctx.get_config_bool(Config::WebxdcRealtimeEnabled).await? {
let Some(iroh) = ctx.get_peer_channel().await else {
warn!(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need in the warning as this is a normal case

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in a perfect world, DC clients shouldn't call this when they know that the channel has not been initialized. But also feel free to apply the suggestion.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no API to know whether the peer channels are initialized. They just initialize lazily. Even if such an API appears, using it will cause race conditions as the peer channels may be initialized in parallel

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if I'm following. Take a look at our WebXDC preload in Desktop:

https://github.com/deltachat/deltachat-desktop/blob/1207a1a1e5d57a7a68456693240b862af794b686/packages/target-electron/static/webxdc-preload.js#L124-L141

leave_webxdc_realtime is supposed to be called only if the app invoked joinRealtimeChannel, which invokes sendWebxdcRealtimeAdvertisement, which is supposed to initialize peer_channels in Core. So a DC client knows if an app uses realtime API.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, feel free to ignore this. Not a big deal I guess.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, now i got it that a DC client knows that, but it looks simpler to allow calling leave_webxdc_realtime() unconditionally like it's done currently in DC Desktop

@iequidoo iequidoo requested review from Septias and link2xt September 19, 2025 14:48
@link2xt link2xt merged commit 3680467 into main Sep 20, 2025
18 checks passed
@link2xt link2xt deleted the webxdc-dont-init-realtime-on-leave branch September 20, 2025 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something is not working webxdc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants