aws / aws/aws-toolkit-vscode

SageMaker detached server kills itself when `ps aux` output exceeds Node's default execFile maxBuffer

Open Beginner friendly
#8,811 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
2k
Forks
810
Avg merge
10h 12m
Merged PRs (30d)
7

Description

### Problem

The SageMaker detached SSM-broker server treats *any* error from its `ps aux` IDE-liveness check as "no IDE running" and shuts itself down. Node's `execFile` has a default `maxBuffer` of 1 MiB, so on a machine where `ps aux` output exceeds 1 MiB, the very first watchdog check fails with `ERR_CHILD_PROCESS_STDIO_MAXBUFFER`, the server exits immediately after starting, and every subsequent SageMaker remote-SSH connection fails with `Failed to get SSM session info. HTTP status: 000` (the `sagemaker_connect` ProxyCommand curls a port nothing is listening on).

`ps aux` exceeding 1 MiB is easy to hit — any other process with a large argv (e.g. a tool that inlines a startup script as a command-line argument) can push the total over the limit. In my case a single unrelated terminal-multiplexer session added ~1.3 MB of argv and reliably broke all SageMaker connections; closing it fixed them.

### Location

`src/awsService/sagemaker/detached-server/server.js` — the darwin/linux `execFile("ps", [...], cb)` calls inside the IDE-detection function. The `if (err) { resolve(false) }` branch conflates "ps failed" with "no IDE present."

### Logs

```
Detached server listening on http://127.0.0.1:49732 (pid: 35070)
Writing local endpoint info to .../sagemaker-local-server-info.json
No IDE windows found. Shutting down detached server.
```

(start → write info → immediate shutdown, leaving a stale port)

### Suggested fix

Pass an explicit larger `maxBuffer`, e.g.:

```js
execFile("ps", ["aux"], { maxBuffer: 64 * 1024 * 1024 }, (err, stdout) => { ... })
```

Optionally also avoid treating a `ps` error as a definitive "no IDE" signal (e.g. don't shut down on transient `execFile` errors), and/or use `ps -A -o comm=`-style output to keep the buffer small.

### Environment
- AWS Toolkit 4.7.0 (Cursor)
- macOS (darwin)

Contributor guide

Open the contributing guide

Research direction

Start in src/awsService/sagemaker/detached-server/server.js and inspect the darwin/linux IDE-detection function, especially its ps execFile calls and error branch. Reproduce the watchdog check with ps output larger than Node's default buffer, then verify the detached server stays available for SageMaker connections instead of shutting down immediately.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript, node.js
Domain
backend, cloud
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.