Skip to content

feat: include VS Code-side logs in support bundle#916

Merged
EhabY merged 5 commits intomainfrom
feat/support-bundle-vscode-logs
Apr 27, 2026
Merged

feat: include VS Code-side logs in support bundle#916
EhabY merged 5 commits intomainfrom
feat/support-bundle-vscode-logs

Conversation

@EhabY
Copy link
Copy Markdown
Collaborator

@EhabY EhabY commented Apr 22, 2026

After the CLI generates the support bundle zip, this appends logs from three VS Code-side sources under a vscode-logs/ directory:

  • Remote SSH extension log — single file from SshProcessMonitor.getLogFilePath()
  • SSH proxy logs — all files from PathResolver.getProxyLogPath(), filtered to the last 3 days by mtime
  • Extension output channel logs — all files from PathResolver.getCodeLogDir(), filtered to the last 3 days by mtime

Each source is collected independently. If a source is unavailable or a file cannot be read, it is warned and skipped. If the zip read/merge/write fails, the original bundle is left untouched and any partial sibling is cleaned up. If the atomic rename step fails, the merged zip is left alongside the original as <name>-vscode.zip and that path is surfaced in a warning log so the user can still find their bundle.

Uses fflate (zero dependencies, 8kB minified, tree-shakeable) via its async zip / unzip callbacks wrapped with node:util.promisify. Memory is bounded by on-disk rotation: VS Code rotates extension logs per session, and SshProcessMonitor caps proxy logs at 20 files / 7 days, so the in-memory peak stays small.

Files changed
File Change
package.json / pnpm-lock.yaml Add fflate dependency
src/core/supportBundleLogs.ts Log collection and zip append logic
src/commands.ts Call appendVsCodeLogs after CLI produces the bundle
test/unit/core/supportBundleLogs.test.ts 7 tests covering merge, empty sources, age filtering, unreadable files, rename failure, and corrupt zip

Closes #889

@EhabY EhabY force-pushed the feat/support-bundle-vscode-logs branch from ea2913c to 4ffc75c Compare April 22, 2026 10:12
After the CLI generates the support bundle zip, append logs from three
sources under a vscode-logs/ directory:

- Remote SSH extension log (from SshProcessMonitor)
- SSH proxy logs (from PathResolver.getProxyLogPath())
- Extension output channel logs (from PathResolver.getCodeLogDir())

Each source is collected independently and failures are warned and
skipped. If zip manipulation fails the original file is left as-is.
Writes to a `-vscode.zip` temp file first, then uses renameWithRetry
to atomically replace the original. If rename fails the user still
has the temp file with a descriptive name.

Uses fflate (zero-dep, 8kB, tree-shakeable) to read/modify/write the
zip. Bundle size impact: +753 bytes (dev), negligible in production.

Closes #889
@EhabY EhabY force-pushed the feat/support-bundle-vscode-logs branch from 4ffc75c to f1b1f6b Compare April 22, 2026 10:22
EhabY and others added 3 commits April 22, 2026 11:14
Parse the date embedded in coder-ssh-YYYYMMDD-HHMMSS-<nonce>.log
filenames instead of using fs.stat. Only proxy logs are filtered;
extension logs are included unconditionally.
Replace filename-based timestamp parsing with stat mtime, consistent
with the cleanup logic in sshProcess.ts. The stat call is already made
to skip subdirectories, so this adds zero extra cost.
- Switch fflate to async `unzip`/`zip` via `util.promisify`
- Return `Map<string, Uint8Array>` instead of `Record<>`
- Drop `zipPrefix` param; caller attaches the prefix
- Apply the 3-day mtime filter to extension logs too (was proxy-only)
- Unexport `collectLogFiles`; inline `vscodeBundlePath`
- Parallelize stat+read inside `collectDirFiles`
- Pass raw errors to `logger.warn`/`logger.error` (drop `toError().message`)
- On merge failure, clean up the `-vscode.zip` sibling via
  `fs.rm({ force: true })` wrapped in try/catch so non-ENOENT errors are
  surfaced rather than masked
- Reference the `-vscode.zip` path in the rename-failure warning so the
  user can still find the bundle

Tests: fold collectLogFiles into appendVsCodeLogs, mtime-based
"not touched" assertions, rename-failure + extension-log-age tests,
gate chmod 0o000 to POSIX non-root, assert sibling cleanup on corrupt input.
@EhabY EhabY force-pushed the feat/support-bundle-vscode-logs branch from 2009205 to 5624bbf Compare April 22, 2026 17:19
Copy link
Copy Markdown
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth adding another zip test with 50+ files?

Comment thread src/commands.ts
Comment thread src/core/supportBundleLogs.ts
Comment thread src/core/supportBundleLogs.ts
Comment thread test/unit/core/supportBundleLogs.test.ts Outdated
- Wrap appendVsCodeLogs body in a top-level try/catch so any unexpected
  failure cannot lose the original support bundle.
- Document why LOG_MAX_AGE_MS is 3 days (not the 7-day rotation).
- Strengthen unchanged-bundle assertions with Buffer.compare alongside
  mtime, since mtime alone can be unreliable across filesystems.
- Add a stress test covering 60 files across two source directories.
@EhabY EhabY requested a review from mtojek April 27, 2026 10:26
@EhabY EhabY self-assigned this Apr 27, 2026
Copy link
Copy Markdown
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ship it!

@EhabY EhabY merged commit d8f53c6 into main Apr 27, 2026
6 checks passed
@EhabY EhabY deleted the feat/support-bundle-vscode-logs branch April 27, 2026 11:12
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

Successfully merging this pull request may close these issues.

Include VS Code-side logs in support bundle

2 participants