Skip to content

Vouch request: fix O(n^2) hang in CLI truncateMessage (deploy hangs in CI) #3828

@yonaplast

Description

@yonaplast

Why do you want to contribute?

I hit a real bug while using Trigger.dev at work, tracked down the root cause, and would like to contribute the fix back.

trigger deploy hangs at "Deploying project" with a CPU core pegged near 100% in non-TTY CI environments, even though it runs fine locally in ~1 minute. I profiled it with node --prof and found ~92% of the time is spent in truncateMessage() (packages/cli-v3/src/utilities/windows.ts): in a non-TTY shell process.stdout.columns is undefined, so it assumes a width of 80 and truncates large spinner messages one character at a time while re-scanning the whole string with two ANSI regexes on each iteration — O(n^2). A fast machine absorbs it; slower CI runners don't, so the deploy appears to hang.

I reported it in #3826 and already prepared the fix (a single O(n) forward pass that preserves ANSI sequences, plus skipping truncation when there's no terminal width) in #3827, which was auto-closed because I'm not vouched yet. I'd love to get vouched so I can re-open it.

Prior contributions or relevant experience

I'm a software engineer using Trigger.dev in production; this fix came out of debugging our own CI deploys.

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