Skip to content

fix: pm2 flush reports error for nonexistent process#6098

Open
YoanWai wants to merge 1 commit intoUnitech:masterfrom
YoanWai:fix/flush-specific-app
Open

fix: pm2 flush reports error for nonexistent process#6098
YoanWai wants to merge 1 commit intoUnitech:masterfrom
YoanWai:fix/flush-specific-app

Conversation

@YoanWai
Copy link
Copy Markdown

@YoanWai YoanWai commented Mar 25, 2026

Summary

  • When pm2 flush <app_name> or pm2 flush <app_id> targets a process that does not exist, PM2 now prints an error instead of silently printing "Logs flushed"
  • Adds a found flag to track whether any process matched the given name/id
  • Adds test coverage for pm_id-based flushing and the not-found error case

Previously, running pm2 flush nonexistent would print [PM2] Logs flushed even though no logs were actually flushed, giving the user misleading feedback.

Test plan

  • npm test passes (flush.mocha.js)
  • Flush all (no argument) still works
  • Flush by app name works and only flushes that app
  • Flush by pm_id works and only flushes that process
  • Flush with nonexistent name/id returns an error

Closes #4553

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 25, 2026

CLA assistant check
All committers have signed the CLA.

When pm2 flush is called with an app name or id that does not match
any running process, it previously printed "Logs flushed" even though
nothing was actually flushed. This is misleading.

Now it prints an error and returns an error callback when the
specified process is not found. Also adds tests for pm_id-based
flushing and the not-found error case.

Closes Unitech#4553
@YoanWai YoanWai force-pushed the fix/flush-specific-app branch from 28696c5 to 64a9e88 Compare March 25, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flush log for a specific app

2 participants