Skip to content

Merge sky into main 20260322#109

Merged
openleek merged 14 commits into
mainfrom
merge-sky-into-main-20260322
Mar 21, 2026
Merged

Merge sky into main 20260322#109
openleek merged 14 commits into
mainfrom
merge-sky-into-main-20260322

Conversation

@openleek

Copy link
Copy Markdown
Member

Pull Request Template

Important Notice

All pull requests must target the develop branch. PRs opened against main will be closed.

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactor
  • Performance improvement
  • Test addition/improvement
  • Build/deployment change

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

  • Unit tests
  • Integration tests
  • Manual tests
  • End-to-end tests

Checklist

Please tick all the boxes that apply to your PR:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have updated the documentation where necessary.
  • I have added an entry to the CHANGELOG.md if my changes are user-visible.

Additional Information

Add any other information about the PR here, such as:

  • Screenshots or videos demonstrating the changes
  • Technical debt addressed
  • Known issues or limitations
  • Suggestions for testing
  • Other considerations

Code Review Checklist

The following items will be checked by the reviewer:

  • Code follows project guidelines
  • Tests are comprehensive and pass
  • Documentation is updated
  • Changes are backward compatible
  • Security implications are considered
  • Performance implications are considered

Thank you for your contribution! 🎉

openleek and others added 14 commits March 19, 2026 18:28
- Pre-allocate dataBuffer with 4096 capacity to reduce allocations
- Increase tmpBuffer from 1KB to 4KB for better read performance
- Copy remainingBuffer to new slice after message processing to
  prevent the underlying array from being held in memory
- Applied to both center and agent handleConnection
- Add 10s timeout to tls.Dial via tls.DialWithDialer to prevent
  indefinite hangs when agent is unreachable
- Reduce WebSocket WriteBufferSize from 10MB to 64KB for both
  SSH and Agent terminal handlers to lower per-connection memory
- ExecuteCommand/ExecuteAction/ExecuteCommandGroup: buffered responseCh
  with non-blocking send to prevent sender goroutine from blocking
  permanently after timeout
- UploadFile/DownloadFile: same pattern for file response channels
- processSessionMessage: use per-case lock instead of function-level lock
  to avoid holding lock during channel send operations
- Replace direct SessionMessageChan send with enqueueSessionMessage()
  which safely handles closed sessions via select+done pattern
- AgentWebSocketSession: add done channel, closeOnce, Close() method
  to prevent double-close panics and resource leaks
- Buffer SessionMessageChan to 16 to reduce blocking
- sendComboOutput: listen on aws.done to exit when session closes
- LogStream: add done channel and cleanRoutine() to periodically
  clean stale writers/readers that lost their connection
- LogStream.Close(): signal done channel to stop clean routine
- log.go: re-enable clearTaskStuff() to properly clean LogStream
  tasks, readers, writers, and watchers when SSE connections end
- Fix error handling: don't return error when GetAgentConn fails
  during task cleanup (task may already be disconnected)
- Remove dead commented-out code
- Add connDone channel to signal connection loss to all session
  goroutines, preventing leaked goroutines on disconnect
- Add sessionForwarders map to track per-session done channels,
  with replaceSessionForwarder/clearSessionForwarder helpers
- cleanupAllReaders: close all active LogStream readers on disconnect
- cleanupAllSessionForwarders: signal all forwarders on disconnect
- waitForSessionOutput: exit on connDone or forwarderDone, release
  non-persistent sessions (bash) when connection drops
- terminal/session.go: add closeOnce/waitOnce for safe idempotent
  close and wait; Attach() returns error; add waitCmd() helper
- terminal/manager.go: DetachSession releases and removes
  non-persistent sessions; AttachSession returns attach errors
在 set -euo pipefail 下,tr /dev/urandom | head 会因 SIGPIPE 返回退出码 141,
导致首次安装时脚本在密码生成步骤静默终止,后续所有安装步骤均未执行。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
当 GitHub API 被限流或返回异常响应时,grep 匹配不到 tag_name 返回退出码 1,
pipefail + set -e 导致脚本静默退出,无法显示 "获取最新版本失败" 的错误提示。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
之前 set -euo pipefail 导致任何未处理的错误都会静默退出,
用户完全看不到发生了什么。现在在 EXIT trap 中检测退出码,
异常退出时显示错误提示和日志路径。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
通过 ERR trap 捕获失败命令的详细信息,在 EXIT trap 中展示给用户,
方便定位问题。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@openleek openleek merged commit f04980b into main Mar 21, 2026
1 of 5 checks passed
@openleek openleek deleted the merge-sky-into-main-20260322 branch March 21, 2026 23:46
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.

2 participants