Skip to content

test:cover reloadLogs twice in fork mode with /dev/null log path - #6164

Open
belte42 wants to merge 1 commit into
Unitech:developmentfrom
belte42:test/reload-logs-null-5509
Open

belte42 wants to merge 1 commit into
Unitech:developmentfrom
belte42:test/reload-logs-null-5509

Conversation

@belte42

@belte42 belte42 commented Sep 26, 2026 •

Copy link
Copy Markdown
Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets Unitech/pm2#5509
License MIT
Doc PR n/a

Nice seeing that the reloadLogs issue has been fixed in the development branch already!

This PR adds a regression test for Unitech/pm2#5509 to test/e2e/logs/log-reload.sh.

In fork mode, pm2 reloadLogs worked the first time, then failed on every later call when a log path was /dev/null or NULL:

TypeError: Cannot read properties of undefined (reading '_file')

The real log files were never reopened, so PM2 kept writing to the rotated files. With logrotate, the logs grew without limit. This still happens on the latest (7.0.4) release

development already fixes it in StdioLogger.close (the if (stds[k] && stds[k]._file) guard). There is no test for it yet, so this adds one to keep it fixed.

Test

Fork mode, -o /dev/null -e err-rel.log. The test deletes the error log, runs reloadLogs, checks the log is recreated, then does the same a second time.

  • On master / 7.0.4: the second check fails.
  • On development: all checks pass.

@CLAassistant

CLAassistant commented Sep 26, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@belte42 belte42 changed the title cover reloadLogs twice in fork mode with /dev/null log path test:cover reloadLogs twice in fork mode with /dev/null log path Sep 26, 2026
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.

2 participants