Skip to content

bug: CLI deploy hangs (100% CPU) in non-TTY CI — truncateMessage() is O(n²) #3826

@yonaplast

Description

@yonaplast

Provide environment information

Bug reproduces in CI (not on the dev machine above):

  • CircleCI machine executor: Ubuntu 24.04, x86_64, Node 22.16.0
  • trigger.dev / @trigger.dev/sdk: 4.4.6
  • Deploy build image: node:21.7.3-bookworm-slim

Describe the bug

Trigger deploy hangs on "Deploying project" for ~30 min (CI timeout) on a non-TTY runner. node --prof shows ~92% CPU usage on RegExpReplace / StringPrototypeReplace / truncateMessage (packages/cli-v3/src/utilities/windows.ts). On a non-TTY, process.stdout.columns is undefined → truncateMessage assumes 80 and truncates large spinner messages character by character by rescanning the entire string with two ANSI regex on each iteration → O(n²). A fast laptop finishes it in ~1 min; a slow CI core does not. Expected: no truncation when there is no TTY, and O(n) truncation.

Reproduction repo

No standalone repro repo; root cause is in windows.ts (analysis above) and a fix PR follows.

To reproduce

  1. A project with a large task graph (tasks importing a big module graph).
  2. Run trigger deploy (CLI 4.4.6) in a non-TTY CI runner (e.g. CircleCI).
  3. It hangs at "Deploying project" with one CPU core at ~100% until timeout.
    Forcing a plain/ballmer spinner (no truncateMessage) or widening process.stdout.columns confirms it.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions