Skip to content

Early comm messages to widget are lost #803

@iisakkirotko

Description

@iisakkirotko

Describe the bug

When, for example, widget traits are changed quickly after the creation of the widget, these updates would not be received by the widget. This happens because the widget model is loaded asynchronously by solid.createResource at

this.#widget_result = solid.createResource(esm, async (update) => {
await safe_cleanup(cleanup, "initialize");
try {
model.off(null, null, INITIALIZE_MARKER);
let widget = await load_widget(update, model.get("_anywidget_id"));

Any comm messages that are sent before load_widget resolves are lost.

Reproduction

Take a look at this PyCafe example. If you open the developer console, you can see that none of the change-triggered console messages are sent.

I also think that plotly/plotly.py#4933 (which was fixed differently in plotly/plotly.py#4956) was ultimately due to this behaviour.

Logs

System Info

System info
System:
    OS: macOS 15.3
    CPU: (10) arm64 Apple M2 Pro
    Memory: 909.98 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
Browsers:
    Chrome: 133.0.6943.127
    Safari: 18.3
    Safari Technology Preview: 18.2
-e file:///Users/iisakki/Code/iisakkirotko/anywidget
jupyter-client==8.6.3
jupyter-core==5.7.2
jupyter-events==0.12.0
jupyter-lsp==2.2.5
jupyter-server==2.15.0
jupyter-server-terminals==0.5.3
jupyterlab==4.3.5
jupyterlab-pygments==0.3.0
jupyterlab-server==2.27.3
jupyterlab-widgets==3.0.13
notebook==7.3.2
notebook-shim==0.2.4

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions