Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PM2 throws errors when used with projects managed by GIT #5696

Open
thavus opened this issue Oct 20, 2023 · 7 comments
Open

PM2 throws errors when used with projects managed by GIT #5696

thavus opened this issue Oct 20, 2023 · 7 comments

Comments

@thavus
Copy link

thavus commented Oct 20, 2023

What's going wrong?

When I start any PM2 app, I see the following error, over and over. The server starts, errors then tries to restart.

PM2         | ===============================================================================
PM2         | --- PM2 global error caught ---------------------------------------------------
PM2         | Time                 : Fri Oct 20 2023 11:41:22 GMT-0400 (Eastern Daylight Time)
PM2         | The argument 'path' must be a string or Uint8Array without null bytes. Received 'C:\\Users\\Sean\\Documents\\Ream\\.git\\\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0...
PM2         | TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string or Uint8Array without null bytes. Received 'C:\\Users\\Sean\\Documents\\Ream\\.git\\\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0...
PM2         |     at Object.readFile (node:fs:393:10)
PM2         |     at Object.readFile (C:\Users\Sean\AppData\Roaming\npm\node_modules\pm2\node_modules\git-node-fs\lib\node-fs.js:18:10)
PM2         |     at Object.readRef (C:\Users\Sean\AppData\Roaming\npm\node_modules\pm2\node_modules\js-git\mixins\fs-db.js:62:8)
PM2         |     at resolveRef (C:\Users\Sean\AppData\Roaming\npm\node_modules\pm2\node_modules\js-git\mixins\walkers.js:104:8)
PM2         |     at onShallow (C:\Users\Sean\AppData\Roaming\npm\node_modules\pm2\node_modules\js-git\mixins\walkers.js:18:5)
PM2         |     at C:\Users\Sean\AppData\Roaming\npm\node_modules\pm2\node_modules\js-git\mixins\fs-db.js:89:7
PM2         |     at C:\Users\Sean\AppData\Roaming\npm\node_modules\pm2\node_modules\git-node-fs\lib\node-fs.js:23:12
PM2         |     at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3)
PM2         |     at FSReqCallback.callbackTrampoline (node:internal/async_hooks:130:17)
PM2         | ===============================================================================
PM2         | [PM2] Resurrecting PM2

How could we reproduce this issue?

Every time I've seen this error it occurred after I did a push to upstream with GIT. Afterwards, pm2 will start throwing errors related to GIT. I'm not using the watch feature.
To confirm this is in fact the issue: When I moved the project's .git folder outside of the project, there's suddenly no problem at all.

Supporting information

--- PM2 report ----------------------------------------------------------------
Date                 : Fri Oct 20 2023 11:46:48 GMT-0400 (Eastern Daylight Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 5.3.0
node version         : 16.14.2
node path            : not found
argv                 : C:\Program Files\nodejs\node.exe,C:\Users\Sean\AppData\Roaming\npm\node_modules\pm2\lib\Daemon.js
argv0                : node
user                 : undefined
uid                  : N/A
gid                  : N/A
uptime               : 5min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 5.3.0
node version         : 16.14.2
node path            : not found
argv                 : C:\Program Files\nodejs\node.exe,C:\Users\Sean\AppData\Roaming\npm\node_modules\pm2\bin\pm2,report
argv0                : node
user                 : Sean
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : win32
type                 : Windows_NT
cpus                 : Intel(R) Core(TM) i7-10875H CPU @ 2.30GHz
cpus nb              : 16
freemem              : 22190993408
totalmem             : 34108944384
home                 : C:\Users\Sean
===============================================================================
--- PM2 list -----------------------------------------------
┌────┬─────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name        │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user
     │ watching │
├────┼─────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0  │ page-app    │ default     │ N/A     │ cluster │ N/A      │ 0      │ 0    │ stopped   │ 0%       │ 0b       │ Sean
     │ disabled │
│ 1  │ user-app    │ default     │ N/A     │ cluster │ N/A      │ 0      │ 0    │ stopped   │ 0%       │ 0b       │ Sean
     │ disabled │
└────┴─────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
C:\Users\Sean\.pm2\pm2.log last 20 lines:
PM2        | 2023-10-20T11:41:26: PM2 log: ===============================================================================
PM2        | 2023-10-20T11:41:26: PM2 error: [PM2] Resurrecting PM2
PM2        | 2023-10-20T11:41:26: PM2 log: pid=25252 msg=process killed
PM2        | 2023-10-20T11:41:27: PM2 log: PM2 successfully stopped
PM2        | 2023-10-20T11:41:27: PM2 log: ===============================================================================
PM2        | 2023-10-20T11:41:27: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
PM2        | 2023-10-20T11:41:27: PM2 log: Time                 : Fri Oct 20 2023 11:41:27 GMT-0400 (Eastern Daylight Time)
PM2        | 2023-10-20T11:41:27: PM2 log: PM2 version          : 5.3.0
PM2        | 2023-10-20T11:41:27: PM2 log: Node.js version      : 16.14.2
PM2        | 2023-10-20T11:41:27: PM2 log: Current arch         : x64
PM2        | 2023-10-20T11:41:27: PM2 log: PM2 home             : C:\Users\Sean\.pm2
PM2        | 2023-10-20T11:41:27: PM2 log: PM2 PID file         : C:\Users\Sean\.pm2\pm2.pid
PM2        | 2023-10-20T11:41:27: PM2 log: RPC socket file      : \\.\pipe\rpc.sock
PM2        | 2023-10-20T11:41:27: PM2 log: BUS socket file      : \\.\pipe\pub.sock
PM2        | 2023-10-20T11:41:27: PM2 log: Application log path : C:\Users\Sean\.pm2\logs
PM2        | 2023-10-20T11:41:27: PM2 log: Worker Interval      : 30000
PM2        | 2023-10-20T11:41:27: PM2 log: Process dump file    : C:\Users\Sean\.pm2\dump.pm2
PM2        | 2023-10-20T11:41:27: PM2 log: Concurrent actions   : 2
PM2        | 2023-10-20T11:41:27: PM2 log: SIGTERM timeout      : 1600
PM2        | 2023-10-20T11:41:27: PM2 log: ===============================================================================

@thavus
Copy link
Author

thavus commented Oct 20, 2023

Uhhh when I moved the project's .git folder outside of the project, there's suddenly no problem at all. Why? I'm so confused. Why is PM2 dipping into my .git folder? Updated the issue report with this info.

My servers are located in a child folder of my main project folder, while my .git folder is located in the parent project folder. I have no idea how pm2 is traversing up several folders outside the scope of my applications and then dipping into the .git folder.

@thavus
Copy link
Author

thavus commented Oct 24, 2023

Here is how I fixed this problem for myself.

  1. End all PM2 processes.
  2. git remote rm origin to remove the origin from git.
  3. git remote add origin UrlOfYourOrigin
  4. Important: Restart your PC.
  5. You should be able to start PM2 now.

EDIT: This actually does not work. I'm having this problem again months later and these steps are not working. I'm not sure what I did last time to resolve it but my only solution now was to create a powershell script to move my .git folder outside of the project so pm2 doesn't have a seizure.

@thavus
Copy link
Author

thavus commented Mar 11, 2024

Several months later, I'm having this problem again and the steps I used before don't seem to be resolving the issue. The only thing that works is to remove .git folder from my project entirely. Once again, the problem started occuring randomly without much reason why it has happened. I did do a push to my git repo before I logged off last Friday. But why is PM2 messing with my .git folder?

I'm not using the watching feature of pm2. I also tried including the "ignore_watch" parameter with '\.git' added to my ecosystem and the issue still occurred.

@thavus
Copy link
Author

thavus commented Mar 11, 2024

I tried setting watch to false for all apps in my ecosystem and the issue persists.

@thavus
Copy link
Author

thavus commented Mar 11, 2024

... my fix was I made a powershell script to move .git to my desktop before the pm2 start eco runs .... jesus christ what a shit show.

@thavus thavus changed the title PM2 global error caught: 'path' must be a string PM2 does not play nice with GIT Mar 11, 2024
@thavus thavus changed the title PM2 does not play nice with GIT PM2 does not work well with GIT Mar 11, 2024
@thavus thavus changed the title PM2 does not work well with GIT PM2 throws errors when used with projects managed by GIT Mar 11, 2024
@thavus
Copy link
Author

thavus commented Mar 11, 2024

Updated the details of this bug to better reflect the problem in case anyone looks at this in the future.

@Unitech
Copy link
Owner

Unitech commented Nov 15, 2024

I have disabled vision by default in the prochain release of PM2,
Could you make a try and let me know if that works for you:

npm install pm2-beta -g
pm2 update

Or with bun:

bun install pm2-beta -g
pm2 update

Thanks

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

No branches or pull requests

2 participants