-
Notifications
You must be signed in to change notification settings - Fork 270
[codex] Fix process list count limit #1865
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,11 +16,10 @@ const CAPABILITY_SCRIPT_POSIX = [ | |
| const PROCESS_LIST_SCRIPT_POSIX = [ | ||
| "exec sh -c ", | ||
| "'", | ||
| // Safety cap: head -n 2000 prevents maxBuffer/timeout on process-dense hosts. | ||
| // This is NOT a functional limit — monitored processes still show accurate metrics. | ||
| "ps -eo pid= -o ppid= -o user= -o stat= -o pcpu= -o pmem= -o rss= -o vsz= -o etime= -o args= 2>/dev/null | head -n 2000", | ||
| "ps -eo pid= -o ppid= -o user= -o stat= -o pcpu= -o pmem= -o rss= -o vsz= -o etime= -o args= 2>/dev/null", | ||
| "'", | ||
| ].join(""); | ||
| const PROCESS_LIST_MAX_BUFFER = 64 * 1024 * 1024; | ||
|
|
||
| function parseCapabilities(stdout, isLocal, localPlatform) { | ||
| const text = stdout || ""; | ||
|
|
@@ -166,10 +165,8 @@ function createSystemManagerBridge(deps) { | |
| if (!sessionId) return { success: false, error: "Missing sessionId" }; | ||
|
|
||
| if (isLocalSession(sessionId) && process.platform === "win32") { | ||
| // Safety cap: -First 2000 prevents maxBuffer/timeout on process-dense hosts. | ||
| // This is NOT a functional limit — monitored processes still show accurate metrics. | ||
| const result = await execOnLocalMachine( | ||
| "Get-CimInstance Win32_Process | Sort-Object KernelModeTime -Descending | Select-Object -First 2000 ProcessId,ParentProcessId,Name,WorkingSetSize | ConvertTo-Json -Compress", | ||
| "Get-CimInstance Win32_Process | Sort-Object KernelModeTime -Descending | Select-Object ProcessId,ParentProcessId,Name,WorkingSetSize | ConvertTo-Json -Compress", | ||
| 10000, | ||
| ); | ||
|
Comment on lines
168
to
172
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On local Windows sessions this command now removes the Useful? React with 👍 / 👎. |
||
| if (!result.success) return { success: false, error: result.error }; | ||
|
|
@@ -194,7 +191,9 @@ function createSystemManagerBridge(deps) { | |
| } | ||
| } | ||
|
|
||
| const result = await execOnSession(event, sessionId, PROCESS_LIST_SCRIPT_POSIX, 12000); | ||
| const result = await execOnSession(event, sessionId, PROCESS_LIST_SCRIPT_POSIX, 12000, { | ||
| maxBuffer: PROCESS_LIST_MAX_BUFFER, | ||
| }); | ||
|
Comment on lines
+195
to
+197
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For normal SSH sessions, this Useful? React with 👍 / 👎. |
||
| if (result.pending) return { success: false, pending: true }; | ||
| if (!result.success) return { success: false, error: result.error || "Failed to list processes" }; | ||
| return { success: true, processes: parseProcessLines(result.stdout) }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -664,6 +664,9 @@ main(); | |
| env: { ...process.env, ...session.sshEnv }, | ||
| timeout: timeoutMs, | ||
| encoding: "utf8", | ||
| maxBuffer: Number.isFinite(Number(execOpts.maxBuffer)) && Number(execOpts.maxBuffer) > 0 | ||
| ? Math.floor(Number(execOpts.maxBuffer)) | ||
| : undefined, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
| windowsHide: true, | ||
| }, (err, stdout, stderr) => { | ||
| if (err) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When this runs for a local Linux/macOS session with enough processes or long command lines, removing the row cap lets
psoutput exceedexecOnLocalMachine's 10 MiBexecFilemaxBufferinelectron/bridges/systemManager/execOnSession.cjs; that path resolves as success if any stdout was captured, soparseProcessLinescan silently show only the truncated prefix rather than all processes. ET sessions have an even smaller defaultexecFilebuffer, so this change can also turn large process lists into load failures. The cap removal should be paired with streaming/parsing or an explicit truncation/error path so dense hosts are not still capped by the transport buffer.Useful? React with 👍 / 👎.