fix(deployments): tolerate pm2 jlist warning banners before the JSON - #609
Merged
Conversation
Found live on prod: pm2 prints an 'In-memory PM2 is out-of-date' banner on stdout ahead of the JSON when the daemon predates the CLI (post node upgrade), with ANSI color codes. JSON.parse failed and discovery silently returned an empty list — exactly the silent-broken-probe failure mode the design forbids. - parsePm2Jlist: try clean parse, then scan for the line the array starts on (ANSI escapes contain '[', so plain indexOf is wrong); throw loudly when no array is present - pm2 probe and discovery both use it; discovery failures now log instead of vanishing Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Found during the prod deploy verification of #606–#608:
GET /api/deployments/discoverreturned an empty pm2 list on a box running three pm2 processes. Cause: this host's pm2 daemon predates the CLI (node was upgraded via nvm), sopm2 jlistprints an 'In-memory PM2 is out-of-date' banner on stdout before the JSON, ANSI color codes included.JSON.parsethrew and discovery swallowed it into[]— the exact silent-broken-probe failure mode the monitor design forbids.Fix
parsePm2Jlist(): clean parse first; on failure, locate the line the JSON array starts on (lastIndexOf('\n[')— ANSI escape sequences contain[, so a plainindexOf('[')would hit the color codes) and parse from there; throw a descriptive error when no array exists.9 monitor tests pass; lint + build clean.
🤖 Generated with Claude Code