Unitech / Unitech/pm2

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (2042)

Open
#5,189 10 comments 7 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?

After restarting the server again try to start pm2 service then hapened this.
(node:2024) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency
(Use node --trace-warnings ... to show where the warning was created)
(node:2024) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'chmod' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'cp' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'dirs' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'pushd' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'popd' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'echo' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'tempdir' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'pwd' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'exec' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'ls' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'find' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'grep' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'head' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'ln' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'mkdir' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'rm' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'mv' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'sed' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'set' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'sort' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'tail' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'test' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'to' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'toEnd' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'touch' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'uniq' of module exports inside circular dependency
(node:2024) Warning: Accessing non-existent property 'which' of module exports inside circular dependency

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (2042)

How could we reproduce this issue?

restart the server and try to start the pm2 server.

Supporting information

--- PM2 report ----------------------------------------------------------------
Date                 : Tue Sep 28 2021 04:32:51 GMT+0000 (Coordinated Universal Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 4.2.3
node version         : 14.15.5
node path            : /usr/local/bin/pm2
argv                 : /usr/bin/node,/usr/local/share/.config/yarn/global/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : root
uid                  : 0
gid                  : 0
uptime               : 28min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 4.2.3
node version         : 14.15.5
node path            : /usr/local/bin/pm2
argv                 : /usr/bin/node,/usr/local/bin/pm2,report
argv0                : node
user                 : root
uid                  : 0
gid                  : 0
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Xeon(R) Gold 5120 CPU @ 2.20GHz
cpus nb              : 2
freemem              : 347742208
totalmem             : 1876996096
home                 : /root
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬───────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name      │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼───────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ server    │ default     │ N/A     │ fork    │ 2145     │ 25m    │ 0    │ online    │ 0%       │ 62.2mb   │ root     │ disabled │
└─────┴───────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/root/.pm2/pm2.log last 20 lines:
PM2        | 2021-09-28T04:04:28: PM2 log: BUS socket file      : /root/.pm2/pub.sock
PM2        | 2021-09-28T04:04:28: PM2 log: Application log path : /root/.pm2/logs
PM2        | 2021-09-28T04:04:28: PM2 log: Worker Interval      : 30000
PM2        | 2021-09-28T04:04:28: PM2 log: Process dump file    : /root/.pm2/dump.pm2
PM2        | 2021-09-28T04:04:28: PM2 log: Concurrent actions   : 2
PM2        | 2021-09-28T04:04:28: PM2 log: SIGTERM timeout      : 1600
PM2        | 2021-09-28T04:04:28: PM2 log: ===============================================================================
PM2        | 2021-09-28T04:07:04: PM2 log: App [server:0] starting in -fork mode-
PM2        | 2021-09-28T04:07:04: PM2 error: TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (2145)
PM2        |     at Object.writeFileSync (fs.js:1460:5)
PM2        |     at /usr/local/share/.config/yarn/global/node_modules/pm2/lib/God/ForkMode.js:264:12
PM2        |     at wrapper (/usr/local/share/.config/yarn/global/node_modules/pm2/node_modules/async/internal/once.js:12:16)
PM2        |     at next (/usr/local/share/.config/yarn/global/node_modules/pm2/node_modules/async/waterfall.js:96:20)
PM2        |     at /usr/local/share/.config/yarn/global/node_modules/pm2/node_modules/async/internal/onlyOnce.js:12:16
PM2        |     at WriteStream.<anonymous> (/usr/local/share/.config/yarn/global/node_modules/pm2/lib/Utility.js:186:13)
PM2        |     at WriteStream.emit (events.js:315:20)
PM2        |     at WriteStream.EventEmitter.emit (domain.js:529:15)
PM2        |     at internal/fs/streams.js:380:12
PM2        |     at FSReqCallback.oncomplete (fs.js:171:23)
PM2        | 2021-09-28T04:07:04: PM2 log: App [server:0] online

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 at lib/God/ForkMode.js:264, where the report shows fs.writeFileSync receiving the process ID as a number. Reproduce the restart-and-start sequence with the PM2 4.2.3 environment described, then trace the surrounding output-file handling. Done means the same startup path no longer throws ERR_INVALID_ARG_TYPE and its behavior is covered by an appropriate existing test.

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.