-
Notifications
You must be signed in to change notification settings - Fork 999
fix(pty-daemon): raise daemon RLIMIT_NOFILE and surface real spawn errno #5067
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 all 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 | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -142,6 +142,21 @@ function validateDims(cols: number, rows: number): void { | |||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| function reprobeErrno(meta: SessionMeta): string { | ||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||
| const probe = childProcess.spawnSync(meta.shell, ["-c", ":"], { | ||||||||||||||||||||||||
| cwd: meta.cwd, | ||||||||||||||||||||||||
| timeout: 1000, | ||||||||||||||||||||||||
| stdio: "ignore", | ||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||
|
Comment on lines
+147
to
+151
Contributor
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. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify parity between nodePty.spawn and reprobeErrno spawnSync options in Pty.ts
fd -i 'Pty.ts' | xargs -I{} sh -c '
echo "== {} ==";
rg -n -C3 "nodePty\\.spawn\\(|spawnSync\\(" "{}";
rg -n -C2 "env:\\s*meta\\.env" "{}";
'Repository: superset-sh/superset Length of output: 958 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Matched files by fd -i 'Pty.ts':"
fd -i 'Pty\.ts$' .
echo
echo "---- reprobeErrno block ----"
sed -n '120,220p' packages/pty-daemon/src/Pty/Pty.ts | cat -n
echo
echo "---- Search for spawnSync options containing env: meta.env ----"
rg -n --context 2 "spawnSync\\(" packages/pty-daemon/src/Pty/Pty.ts
rg -n --context 2 "env:\\s*meta\\.env" packages/pty-daemon/src/Pty/Pty.tsRepository: superset-sh/superset Length of output: 4552 🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n "type SessionMeta|interface SessionMeta|SessionMeta" packages/pty-daemon/src/Pty/Pty.ts packages/pty-daemon/src -SRepository: superset-sh/superset Length of output: 1959 🏁 Script executed: #!/bin/bash
set -euo pipefail
sed -n '1,120p' packages/pty-daemon/src/protocol/messages.ts | nl -baRepository: superset-sh/superset Length of output: 107 🏁 Script executed: #!/bin/bash
set -euo pipefail
sed -n '1,120p' packages/pty-daemon/src/protocol/messages.ts | cat -nRepository: superset-sh/superset Length of output: 3608 Preserve spawn parity in
Suggested patch function reprobeErrno(meta: SessionMeta): string {
try {
const probe = childProcess.spawnSync(meta.shell, ["-c", ":"], {
cwd: meta.cwd,
+ env: meta.env,
timeout: 1000,
stdio: "ignore",
});📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| if (!probe.error) return "ok"; | ||||||||||||||||||||||||
|
Contributor
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 the re-probe succeeds (the EMFILE condition resolved between node-pty's failure and Prompt To Fix With AIThis is a comment left during a code review.
Path: packages/pty-daemon/src/Pty/Pty.ts
Line: 152
Comment:
**`"ok"` in error message is confusing**
When the re-probe succeeds (the EMFILE condition resolved between node-pty's failure and `spawnSync`), the thrown error message reads `errno=ok`, which is contradictory — the caller sees an exception but with a result string that implies success. A label like `"non-sticky"` or `"resolved"` would make it immediately clear that the condition was transient rather than suggesting the probe found no error.
How can I resolve this? If you propose a fix, please make it concise.
Contributor
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. P3: Returning Prompt for AI agents
Suggested change
|
||||||||||||||||||||||||
| const e = probe.error as NodeJS.ErrnoException; | ||||||||||||||||||||||||
| return e.code ?? e.message; | ||||||||||||||||||||||||
| } catch (e) { | ||||||||||||||||||||||||
| return `reprobe-failed:${(e as Error).message}`; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| export function spawn({ meta }: SpawnOptions): Pty { | ||||||||||||||||||||||||
| validateDims(meta.cols, meta.rows); | ||||||||||||||||||||||||
| // Pre-flight: node-pty's "posix_spawnp failed" message swallows errno | ||||||||||||||||||||||||
|
|
@@ -178,9 +193,11 @@ export function spawn({ meta }: SpawnOptions): Pty { | |||||||||||||||||||||||
| encoding: null, | ||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||
| } catch (err) { | ||||||||||||||||||||||||
| // Annotate with shell + cwd so the wire-error reply is actionable. | ||||||||||||||||||||||||
| // node-pty's native "posix_spawnp failed." drops the errno, so re-probe | ||||||||||||||||||||||||
| // the same shell+cwd with spawnSync to surface the real code (e.g. | ||||||||||||||||||||||||
| // EMFILE/EAGAIN/ENOENT). | ||||||||||||||||||||||||
| throw new Error( | ||||||||||||||||||||||||
| `spawn failed (shell=${meta.shell} cwd=${meta.cwd ?? "(none)"}): ${(err as Error).message}`, | ||||||||||||||||||||||||
| `spawn failed (shell=${meta.shell} cwd=${meta.cwd ?? "(none)"} errno=${reprobeErrno(meta)}): ${(err as Error).message}`, | ||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| const adapter = new NodePtyAdapter(term, meta); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
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.
P2: Errno reprobe does not use the same environment as the failing spawn, so reported errno can be incorrect/misleading.
Prompt for AI agents