Skip to content

dispose() causes an error with canvas renderer #4757

@dstein64

Description

@dstein64

The terminal's dispose() method leads to an uncaught error when using a canvas renderer. This started with the latest release ([email protected] and [email protected]).

Details

  • Browser and browser version: Chrome 116
  • OS version: Kubuntu 23.04
  • xterm.js version: 5.3.0

Steps to reproduce

Create a page with the following code:

<!doctype html>
<html>
<head>
    <link rel="stylesheet" href="https://unpkg.com/[email protected]/css/xterm.css" />
    <script src="https://unpkg.com/[email protected]/lib/xterm.js"></script>
    <script src="https://unpkg.com/[email protected]/lib/xterm-addon-canvas.js"></script>
</head>
<body>
<div id="terminal"></div>
<script>
    const term = new Terminal();
    term.loadAddon(new CanvasAddon.CanvasAddon());
    term.open(document.getElementById('terminal'));
    term.writeln('Hello world!');
</script>
</body>
</html>

In the developer console, type term.dispose().

The following error message is printed to the console:

RenderService.ts:206 Uncaught TypeError: Cannot read properties of undefined (reading 'onRequestRedraw')
    at t.RenderService.setRenderer (RenderService.ts:206:26)
    at Object.dispose (CanvasAddon.ts:62:21)
    at a.dispose (Lifecycle.ts:22:9)
    at t.AddonManager._wrappedAddonDispose (AddonManager.ts:50:25)
    at t.dispose (AddonManager.ts:30:35)
    at t.AddonManager.dispose (AddonManager.ts:19:32)
    at d.dispose (Lifecycle.ts:22:9)
    at d.dispose (Terminal.ts:195:11)
    at <anonymous>:1:6

This does not occur when the canvas add-on is not used.

Metadata

Metadata

Assignees

Labels

type/bugSomething is misbehaving

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions