TypeError accessing `container.id` on window resize in ContainerDetailsTerminal

Author: dgolovinCreated Jul 31, 2026Updated Sep 18, 2026
Labelsos/macOS 🍎area/terminaldomain/containers

Bug description

Opening a container’s Terminal tab and resizing the window can throw:

TypeError: Cannot read properties of undefined (reading 'id')

This pollutes the console output. It comes from the resize listener in packages/renderer/src/lib/container/ContainerDetailsTerminal.svelte, which builds a route path with container.id without guarding against a missing container:

svelte
  window.addEventListener('resize', () => {
    if (currentRouterPath === `/containers/${container.id}/terminal`) {
      fitAddon.fit();
      if (sendCallbackId) {
        window
          .shellInContainerResize(sendCallbackId, shellTerminal.cols, shellTerminal.rows)
          .catch((err: unknown) => console.error(`Error resizing terminal for container ${container.id}`, err));
      }
    }
  });

A new resize listener is registered every time the terminal view is opened (refreshTerminal / mount), and it is never removed in onDestroy. Listeners therefore accumulate across visits to the terminal tab, and stale handlers can still run after the component unmounts or after container is no longer available (for example when the engine/provider goes away).

There is no matching removeEventListener in onDestroy. window holds those handlers; each handler closes over the component instance’s scope (including container, fitAddon, shellTerminal, etc.). As long as the listener exists, that instance and its last container object stay reachable, so the GC can’t reclaim them. Leave and re-enter the tab → another listener → another retained instance.

This was observed together with terminal open/restart failures such as Error: no running provider for the matching engine and a Podman machine socket hang up while listing images — those look like the trigger condition, while the TypeError is the uncaught error on resize.

Operating system

macOS (darwin 25.5.0, Apple silicon)

Installation Method

Other

Version

next (development version)

Steps to reproduce

  1. Start Podman Desktop with a Podman machine / engine that can become unavailable (or stop/restart the machine while the UI is open).
  2. Open a running container → Terminal tab (optionally leave and re-open the tab multiple times to accumulate listeners).
  3. Stop and remove container.
  4. Resize the application window.
  5. Observe: console shows TypeError: Cannot read properties of undefined (reading 'id') from the resize listener using container.id.

After heavily using Podman Desktop, stopping and starting hello container Podman Desktop UI freezes and not remove listener seems to go into recursion.

https://github.com/user-attachments/assets/315115f3-f554-4508-a6a8-ecf422fac161

Relevant log output

bash
TypeError: Cannot read properties of undefined (reading 'id')
    at ContainerDetailsTerminal.svelte:189

Error opening terminal for container <id> Error: no running provider for the matching engine
Error restarting terminal Error: no running provider for the matching engine
Error listing images from provider Podman (podman.podman-machine-default): Error: socket hang up

Additional context

Screenshot from DevTools (Sources) shows the exception on ${container.id} inside the anonymous resize handler. Related but different historical issue: #496 (xterm fit integer error on resize).

Source: podman-desktop/podman-desktop