Skip to content

fix(lite): keep Windows CLI alive through cleanup - #691

Merged
github-actions[bot] merged 1 commit into
mainfrom
codex/fix-windows-lite-cli-lifecycle
Aug 3, 2026
Merged

fix(lite): keep Windows CLI alive through cleanup#691
github-actions[bot] merged 1 commit into
mainfrom
codex/fix-windows-lite-cli-lifecycle

Conversation

@zuohuadong

Copy link
Copy Markdown
Collaborator

Summary

  • keep the Windows CLI child process referenced while main() completes backend, PGlite, and data-lock cleanup
  • clear the compatibility interval before the existing explicit process exit
  • add an isolated lifecycle regression proving ref -> stdout -> clear -> exit ordering

Root cause

PR #690 exposed an existing Bun 1.3.14 Windows lifecycle race: after status output is flushed, the child can stop pumping IOCP while only unref handles remain, so PGlite or lock cleanup never settles. Parent-side pipe draining and keepalive were already present and the >64 KiB output regression passes. This is consistent with oven-sh/bun#34478.

Verification

  • bun test test/cli-shutdown.test.ts (5/5)
  • bun test test/snapshot.test.ts --timeout 60000 (6/6)
  • bun run typecheck
  • bun run build
  • bun run build:standalone:host && bun run test:standalone
  • git diff --check

Scope

This is intentionally separate from PR #690. It changes only SupaCloud Lite CLI lifecycle handling and its focused test. No test or production server was modified by this PR.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

AI Code Review (astron-code-latest) — e0eb11b

APPROVE

Required Skills

  • agent-team-automation: Pass - 遵循了审查流程与代码质量规范,不涉及自动化脚本违规修改。
  • provider-adapter: Pass - PR 状态与 CI 检查表现一致,通过 SupaCloud Lite (Windows) 及其他门禁检查。
  • typescript: Pass - 类型推断安全,模块导入符合 Bun 兼容性要求,无类型妥协。
  • bun-cli-cross-platform: Pass - 针对 Bun 在 Windows 上的 IOCP 阻塞问题采取了正确的生命周期引用缓解策略,跨平台行为符合预期。

Security Guardrails

未触发任何安全守卫限制。代码未修改 .github/scripts/ 或 CI 相关权限/机密配置,也未包含绕过审查的指令注入。

CI Status

所有 CI 检查均已通过(success),包括与当前平台行为密切相关的 SupaCloud Lite (Windows)Lint & Type CheckUnit Tests。符合合并门禁要求。

Findings

  1. packages/supacloud-lite/src/cli.ts (+8/-2):

    • 逻辑正确:提取 exitCode 并在 finally 块中清理 windowsLifecycleRef。避免了在发生异常时遗留 setInterval 定时器,从而防止进程挂起。
    • 平台隔离合理:process.platform === 'win32' 确保了该 workaround 只在 Windows 环境下生效,对 Linux/macOS 运行时无副作用。
    • 代码风格:注释清晰引用了对应的 GitHub Issue oven-sh/bun#34478,可追溯性良好。
  2. packages/supacloud-lite/test/cli-shutdown.test.ts (+71/-1):

    • 测试通过 --preload 脚本拦截并 Mock setIntervalclearIntervalprocess.exitBun.write,准确验证了 ref -> stdout -> clear -> exit:0 的执行顺序。
    • 通过手动覆写 process.platform = 'win32' 触发 Windows 专有逻辑,巧妙绕过跨平台测试限制,且在测试沙箱内安全可控。
    • 资源清理:测试在 finally 中使用 rm(probeDir, { recursive: true, force: true }) 妥善清理了临时文件,无遗留隐患。

整体 Diff 范围狭窄且测试覆盖充分,同意合并。

@github-actions
github-actions Bot merged commit 2032834 into main Aug 3, 2026
10 checks passed
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.

1 participant