Skip to content

Output appended to Output Widget via append_display_data not displayed #16739

Open
@basnijholt

Description

@basnijholt

Environment data

  • VS Code version: Version: 1.101.0
  • Jupyter Extension version (available under the Extensions sidebar): 2025.5.0
  • Python Extension version (available under the Extensions sidebar): 2025.8.0
  • OS MacOS 15.5 (24F74)
  • Python and/or Anaconda version: 3.13.3
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): uv venv && uv pip install ipywidgets notebook
  • Jupyter server running: Local

Expected behaviour

When adding content to Output widgets via append_display_data() asynchronously, the content should appear in the Output widgets.

Actual behaviour

  • Output widgets appear correctly
  • BUT Output widgets render as empty (no content is displayed)
  • Console shows errors: "Model not found in Kernel state to render output" and "vscode.fallbackToNextRenderer"
  • The same code works perfectly in regular Jupyter Lab/Notebook

Steps to reproduce:

Minimal Example (core issue)

The issue occurs with any asynchronous content addition to Output widgets:

import asyncio
from IPython.display import display
from ipywidgets import HTML, Output

outputs = [Output() for _ in range(10)]
display(*outputs)

async def reproduce_bug():
    for i in range(10):
        await asyncio.sleep(0.01)
        outputs[i].append_display_data(HTML(f"Content {i}"))

asyncio.create_task(reproduce_bug())

Root cause: VS Code widget renderer loses track of Output widget state when content is added asynchronously via append_display_data(), causing the renderer to fall back instead of properly rendering the widget content. This affects any async workflow with Output widgets.

Note: This breaks the official recommended pattern for ipywidgets async usage as documented in:

Using append_display_data() in async contexts is the standard way to update widgets from background threads and show progress in long-running operations.

Logs

Output for Jupyter in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Jupyter)

``` nothing relevant ```

Browser Console Errors (from Help > Toggle Developer Tools):

Model not found in Kernel state to render output [id], rendering a fallback mime type
Uncaught (in promise) vscode.fallbackToNextRenderer
    at renderOutputItem (ipywidgetsRenderer.js)

Visual comparison:
(Recorded with a slightly larger MRE, but same problem)

  • In VS Code:
Screen.Recording.2025-06-17.at.14.29.17.mov
  • In Jupyter Notebook:
Screen.Recording.2025-06-17.at.14.30.05.mov

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugipywidgetsRendering, loading, saving, anything to do with IPyWidgets

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions