xtermjs / xterm.js

A terminal for the web
https://xtermjs.org/
MIT License
17.52k stars 1.62k forks source link

Disposing terminal after calling ```fit()``` leads to TypeError #4983

Closed Tomtec331 closed 5 months ago

Tomtec331 commented 7 months ago

Disposing a terminal directly after calling 'fit' leads to an error:

Screenshot 2024-03-05 172233

Background: We are using xterm with react in strict mode. This means that the terminal will be mounted and directly unmounted afterwards. The code shown below is a minimal reproduction of what actually happens (without react lifecycle hooks).

Details

Steps to reproduce

Minimal code to reproduce:

import { Terminal } from '@xterm/xterm';
import { FitAddon } from '@xterm/addon-fit';
import '@xterm/xterm/css/xterm.css';

const div = document.querySelector<HTMLDivElement>('#app')!;
const terminal = new Terminal();
const addon = new FitAddon();

// component mounts
terminal.open(div);
terminal.loadAddon(addon);
addon.fit();
// component unmounts
terminal.dispose();
tisilent commented 7 months ago

reproduce .