turbo icon indicating copy to clipboard operation
turbo copied to clipboard

VSCode terminal crashing in specific case with TUI

Open anthonyshew opened this issue 9 months ago • 9 comments

Original discussion: https://github.com/vercel/turborepo/discussions/10195

Verify canary release

  • [x] I verified that the issue exists in the latest Turborepo canary release.

Link to code that reproduces this issue

N/A

Which canary version will you have in your reproduction?

2.4.4

Environment information

See additional context for information.

Expected behavior

See additional context for information.

Actual behavior

See additional context for information.

To Reproduce

We don't have a clean reproduction for this case. See additional context for information.

Additional context

Summary

Sometimes after completing a task I get characters in the terminal or in the commit message.

Something like this:

35;95;33M35;94;33M35;94;34M35;93;34M35;93;35M35;92;35M35;91;36M35;91;37M35;90;37M35;89;37M35;89;38M35;88;38M35;88;39M35;88;40M35;88;41M35;88;42M35;88;43M

Sometimes they are there, sometimes they are not, I don't see a pattern. They can also appear after the task is completed with git commit --amend. In this case, all these symbols become a commit message, which requires additional changes

{
  "$schema": "https://turbo.build/schema.json",
  "tasks": {
    "pre-commit": {
      "dependsOn": ["lint", "typecheck"]
    },
    "pre-push": {
      "dependsOn": ["test"]
    },
    "build": {
      "dependsOn": ["test", "typecheck", "lint"],
      "outputs": ["dist/**"]
    },
    "build:dev": {
      "outputs": ["dist/**"]
    },
    "build:stage": {
      "dependsOn": ["test", "typecheck", "lint"],
      "outputs": ["dist/**"]
    },
    "build:analyze": {
      "dependsOn": ["build:dev"],
      "outputs": ["dist/**"]
    },
    "preview": {
      "persistent": true,
      "cache": false
    },
    "lint": {
      "dependsOn": ["^lint"]
    },
    "test": {
      "dependsOn": ["^test"]
    },
    "typecheck": {
      "dependsOn": ["^typecheck"]
    },
    "dev": {
      "persistent": true,
      "cache": false
    },
    "clean:turbo": {
      "cache": false,
      "outputs": []
    },
    "clean:node-modules": {
      "cache": false,
      "outputs": []
    },
    "sb": {
      "cache": false
    }
  },
  "ui": "tui"
}

Additional information

- Turbo: 2.4.4
- Node: 18.20.3
- OS: macos Sequoia 15.0.1
- Terminal: iTerm2 3.5.11
- Zsh 5.9 (arm64-apple-darwin24.0)

Example

No response

anthonyshew avatar Mar 21 '25 14:03 anthonyshew

Bringing error logs that were DM'ed to me here:

panicked at crates/turborepo-lib/src/commands/run.rs:64:42:
render thread panicked: JoinError::Panic(Id(46), ...)"""
panicked at crates/turborepo-vt100/src/grid.rs:873:18:
called `Option::unwrap()` on a `None` value"""

anthonyshew avatar Mar 21 '25 14:03 anthonyshew

Our current theory is that the task is writing some bad character to the terminal. We're not handling it well enough, so a crash occurs. We think there's some race condition in one of our underlying libraries but can't confirm without more information.

Can you give us some information about what tools are being used in the task that is crashing? Are there any out-of-the-ordinary characters in the log output? More generally, we're looking for anything that could be atypical being written to the terminal.

anthonyshew avatar Mar 21 '25 14:03 anthonyshew

Attaching the logs for the full crash here:

logs.txt report-84e677ae-a776-4ff9-afa2-aac587bca2ea.txt report-277cdae7-8547-4314-ae38-6fdb3439d2bf.txt

(Last 2 files have been renamed from .toml to .txt)

soulr344 avatar Mar 22 '25 17:03 soulr344

I can also say that this happens regardless of which terminal is used. In my team, this happens to everyone, so I had to switch to "ui": "stream". Let me know what could be the problem or how can I write my own ui.

rettimo avatar Mar 27 '25 14:03 rettimo

@rettimo @soulr344 Can you provide full reproductions?

anthonyshew avatar Mar 27 '25 16:03 anthonyshew

@anthonyshew i did some random stuff and figured out that it happens when turbo is killed

the reproduction steps are: (i verified that this happens on all turborepo projects that i have, all of them are in turbo v 2.4.4).

  • run the dev command in any turbo repo project with tui enabled
  • kill the process with pkill turbo

Then try hovering the mouse over the terminal, it should go crazy.

Let me know if this works. Incase it doesn't, I'll try finding some other way to reproduce.

soulr344 avatar Mar 28 '25 15:03 soulr344

Good find, thank you. We'll sort out a fix.

anthonyshew avatar Apr 05 '25 13:04 anthonyshew

@anthonyshew The root cause of this issue is in these two files https://github.com/vercel/turborepo/blob/main/crates/turborepo-ui/src/tui/app.rs https://github.com/vercel/turborepo/blob/main/crates/turborepo-vt100/src/grid.rs I will take this up

CodeMan62 avatar Apr 13 '25 11:04 CodeMan62

Facing the same issue.

  • Turbo: 2.5.0
  • Node: 22.14.0
  • OS: Windows 10
  • Terminal: cmd

report-28dd3eba-547d-41b7-af51-15c3fcbc8187.txt

Parth-Bhanushali avatar Apr 19 '25 06:04 Parth-Bhanushali