Unitech / Unitech/pm2

process.stdout.write doesn't log in same line (with random line breaks)

Open
#4,026 13 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

What's going wrong?

When using process.stdout.write - output not in the same line. Also the line breaks are random.

How could we reproduce this issue?

// index.js
process.stdout.write('this');
process.stdout.write('should');
process.stdout.write('be');
process.stdout.write('in');
process.stdout.write('one');
process.stdout.write('line');

pm2 start index.js

Output for pm2 logs:

0|index  | this
0|index  | should
0|index  | beinoneline
0|index  | this
0|index  | should
0|index  | beinoneline
0|index  | thisshouldbeinoneline
0|index  | this
0|index  | should
0|index  | bein
0|index  | one
0|index  | line
0|index  | this
0|index  | should
0|index  | beinoneline
0|index  | this
0|index  | shouldbeinone

Supporting information

$ pm2 report

===============================================================================
--- PM2 REPORT (Thu Nov 15 2018 14:01:23 GMT+0200 (Israel Standard Time)) -----
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 3.2.2
node version         : 11.0.0
node path            : /usr/local/bin/pm2
argv                 : /usr/local/Cellar/node/11.0.0/bin/node,/usr/local/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : sasha
uid                  : 501
gid                  : 20
uptime               : 4min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 3.2.2
node version         : 11.0.0
node path            : /usr/local/bin/pm2
argv                 : /usr/local/Cellar/node/11.0.0/bin/node,/usr/local/bin/pm2,report
argv0                : node
user                 : sasha
uid                  : 501
gid                  : 20
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : darwin
type                 : Darwin
cpus                 : Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz
cpus nb              : 4
freemem              : 2403622912
totalmem             : 17179869184
home                 : /Users/sasha
===============================================================================

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the index.js reproduction and run pm2 start index.js followed by pm2 logs to observe how successive process.stdout.write calls are grouped. Trace PM2's log-stream handling to determine why writes receive random line breaks; done means the six writes appear in one line in pm2 logs.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.