Skip to content

How to prevent auto releaseProxy? #667

@HuakunShen

Description

@HuakunShen

I am using comlink to communicate between a web page and an embedded iframe. The iframe calls functions exposed from the main page. Everything works fine when iframe web page is running on dev server (vite), but stops working in production build.

In production build, the API call to main page works for the first ~25ms then stops working (this is not a stable behaviour, sometimes longer). After inspecting all messages from iframe I found a message with type RELEASE.

Then I found this in comlink's docs.

If the browser supports the WeakRef proposal, releaseProxy will be called automatically when the proxy created by wrap() gets garbage collected.

Is there a way to prevent auto release? The iframe page is like an extension, it needs to call APIs exposed from main page throughout its lifetime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions