opensumi / core

🚀 A framework helps you quickly build AI Native IDE products. https://preview.opensumi.com
https://opensumi.com
MIT License
2.89k stars 372 forks source link

fix: add pty socket timeout #3834

Closed winjo closed 2 months ago

winjo commented 3 months ago

Types

Background or solution

pty 双容器下 socket 有概率即没有出发 connnect,也没有触发 close,导致终端一致无法 ready,增加一个 timeout 事件

Changelog

Summary by CodeRabbit

railway-app[bot] commented 3 months ago

This PR was not deployed automatically as @winjo does not have access to the Railway project.

In order to get automatic PR deploys, please add @winjo to the project inside the project settings page.

coderabbitai[bot] commented 3 months ago

Walkthrough

PtyServiceManagerRemote类中进行了多个增强,包括添加了PtyServiceOptions接口以配置重连间隔和套接字超时。构造函数被修改以接受一个可选的options参数,用于自定义配置。同时实现了套接字超时处理和在套接字关闭时以可配置间隔重连的逻辑。在单元测试中,对传递给injector.get的参数对象进行了调整,包含socketConnectOpts以更准确地测试。

Changes

文件路径 变更摘要
packages/terminal-next/src/node/pty.manager.remote.ts PtyServiceManagerRemote类中添加了PtyServiceOptions接口、disposeroptions、和debugLog属性。更新了构造函数以包含可选的options参数,并实现了套接字超时处理和重连逻辑。
packages/terminal-next/tests/node/pty.proxy.test.ts 修改了传递给injector.getuseValue参数,添加了socketConnectOpts以更准确地测试。

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
winjo commented 3 months ago

/next

opensumi[bot] commented 3 months ago

🎉 PR Next publish successful!

3.1.5-next-1720063337.0

bytemain commented 3 months ago

@coderabbitai 有这个pr的原因是因为 node.js 的 socket 在 connect 的时候会 hang 住,没有报错也没有任何回调事件,请问这在什么情况下才会出现呢,有什么好的方案吗

coderabbitai[bot] commented 3 months ago

[!TIP] For best results, initiate chat on the files or code changes.

@bytemain 有这个 PR 的原因是因为在某些情况下,Node.js 的 socket 在连接过程中可能会出现挂起现象,而不会触发错误或回调事件。这种情况通常发生在以下几种情景:

  1. 网络问题:如果网络连接不稳定或存在延迟,socket 可能会挂起。
  2. 防火墙设置:某些防火墙配置可能会阻止连接,导致 socket 挂起。
  3. Node.js 版本问题:某些版本的 Node.js 可能存在 bug,导致 socket 在连接时挂起。

解决方案

  1. 实现超时:在 socket 上实现超时机制,确保在一定时间内没有连接成功时触发超时事件。这正是当前 PR 中所做的改进。
  2. 使用替代库:考虑使用其他更稳定的库,如 net 模块的替代品。
  3. 更新 Node.js:确保使用最新的 Node.js 版本,以避免已知的 bug。

希望这些信息对您有所帮助。如果您有其他问题或需要进一步的帮助,请随时告知。

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 51.28205% with 19 lines in your changes missing coverage. Please review.

Project coverage is 55.02%. Comparing base (29de686) to head (a871d3a). Report is 2 commits behind head on main.

Files Patch % Lines
...kages/terminal-next/src/node/pty.manager.remote.ts 51.28% 18 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #3834 +/- ## ======================================= Coverage 55.02% 55.02% ======================================= Files 1553 1553 Lines 94689 94720 +31 Branches 19373 19384 +11 ======================================= + Hits 52098 52119 +21 - Misses 35385 35392 +7 - Partials 7206 7209 +3 ``` | [Flag](https://app.codecov.io/gh/opensumi/core/pull/3834/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensumi) | Coverage Δ | | |---|---|---| | [jsdom](https://app.codecov.io/gh/opensumi/core/pull/3834/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensumi) | `50.45% <0.00%> (-0.01%)` | :arrow_down: | | [node](https://app.codecov.io/gh/opensumi/core/pull/3834/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensumi) | `15.57% <51.28%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensumi#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

winjo commented 3 months ago

/next

opensumi[bot] commented 3 months ago

🎉 PR Next publish successful!

3.1.5-next-1720065119.0

winjo commented 3 months ago

/next

opensumi[bot] commented 3 months ago

🎉 PR Next publish successful!

3.1.5-next-1720069890.0

winjo commented 3 months ago

/next

opensumi[bot] commented 3 months ago

🎉 PR Next publish successful!

3.1.5-next-1720152351.0