Skip to content

fix: direct debug adapter fix, and runInTerminal fix#4031

Merged
life2015 merged 1 commit intomainfrom
fix/dap-direct-adapter-and-terminal
Sep 19, 2024
Merged

fix: direct debug adapter fix, and runInTerminal fix#4031
life2015 merged 1 commit intomainfrom
fix/dap-direct-adapter-and-terminal

Conversation

@life2015
Copy link
Copy Markdown
Member

@life2015 life2015 commented Sep 19, 2024

Types

修复 DAP 支持 和 OpenSumi Debug 的错误

  • 修复 directDebugAdapter 无法使用的问题

  • 修复 DAP 调用 runInTerminal 后服务端无法拿到 pid 的问题

  • 🐛 Bug Fixes

Background or solution

目前 OpenSumi Debug 对于 directDebugAdapter 的支持有问题,导致插件注册的 directDebugAdapter 无法正常对接 Debug 能力,表现是 DAP 的 IO 完全不通。重写了这部分 IO 对接逻辑后,问题被解决。

另外 RunInTerminal 也有问题,表现是 Debug 时拉起终端运行程序之后,DAP Server 感知不到 Server 被拉起来,同时也拿不到进程的 pid。发现问题在于 RunInTerminal 在 IDE 侧调用后没有 await,就直接返回空结果给 DAP Server。

Changelog

  • direct debug adapter fix
  • runInTerminal no pid response fix

Summary by CodeRabbit

  • 新功能

    • 改进了调试请求的响应处理,支持异步操作,提高了调试过程的可靠性。
    • 引入了新的消息读取和写入类,增强了调试适配器之间的消息通信。
  • 错误修复

    • 添加了防御性检查,确保调试器配置的 JSON 格式正确,避免运行时错误。

@life2015 life2015 requested review from Ricbet and erha19 September 19, 2024 09:22
@railway-app
Copy link
Copy Markdown

railway-app Bot commented Sep 19, 2024

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

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 19, 2024

Walkthrough

此次更改主要集中在调试会话的处理上,增强了对调试请求响应的异步处理能力。引入了新的消息读取和写入类,以改善调试适配器协议(DAP)消息的解析和序列化。此外,增加了对JSON配置的防御性检查,以防止因格式不当而导致的运行时错误。

Changes

文件路径 更改摘要
packages/debug/src/browser/debug-session-connection.ts 修改了调试请求处理程序的类型定义,允许返回异步值,增强了调试请求响应的处理。更新了请求处理程序的调用方式,以确保正确处理异步操作。
packages/extension/src/browser/vscode/contributes/debuggers.ts DebuggersContributionPoint类中添加了防御性检查,以确保处理的属性是对象,从而避免因格式不当的JSON配置导致的运行时错误。
packages/extension/src/hosted/api/vscode/debug/extension-debug-adapter-starter.ts 添加了MessageReaderMessageWriter类以处理DAP消息的读取和写入,修改了directDebugAdapter函数以利用这些新类,从而改善调试适配器的消息处理机制。

Suggested labels

🐞 bug


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
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@opensumi opensumi Bot added the 🐞 bug Something isn't working label Sep 19, 2024
@life2015
Copy link
Copy Markdown
Member Author

/next

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e8e56c1 and b0da78b.

Files selected for processing (3)
  • packages/debug/src/browser/debug-session-connection.ts (3 hunks)
  • packages/extension/src/browser/vscode/contributes/debuggers.ts (1 hunks)
  • packages/extension/src/hosted/api/vscode/debug/extension-debug-adapter-starter.ts (2 hunks)
Additional comments not posted (4)
packages/debug/src/browser/debug-session-connection.ts (3)

12-12: 修改看起来不错!

通过引入 MaybePromise,debug 请求处理程序现在可以返回直接值或 promise,这为异步操作提供了更大的灵活性。


28-28: 类型定义的修改看起来很合理。

通过将 DebugRequestHandler 的返回类型更改为 MaybePromise<any>,与更新后的导入语句保持一致,支持在 debug 请求处理程序中进行异步操作。这使得处理程序能够在提供响应之前执行异步任务。


261-263: 非常重要的修复!

在调用请求处理程序时添加 await 关键字是一个关键的修复。正如注释中提到的,之前缺少 await 会导致服务器无法获取预期的结果,特别是在使用集成控制台进行调试时,会导致无法命中断点。

通过正确地等待异步操作完成,可以确保服务器接收到预期的结果,从而解决了影响调试功能的关键问题。这个修改非常重要,能够显著改善调试体验。

packages/extension/src/browser/vscode/contributes/debuggers.ts (1)

285-288: 非常好的防御性编程实践!

添加这个检查可以提高代码的健壮性,防止由于格式不正确的 JSON 配置导致调试功能完全失败。提前返回可以避免访问 undefined 属性而导致的潜在运行时错误。建议保留这个改动。

@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 5.55556% with 51 lines in your changes missing coverage. Please review.

Project coverage is 54.44%. Comparing base (e8e56c1) to head (b0da78b).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...pi/vscode/debug/extension-debug-adapter-starter.ts 3.92% 45 Missing and 4 partials ⚠️
...ension/src/browser/vscode/contributes/debuggers.ts 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4031      +/-   ##
==========================================
- Coverage   54.46%   54.44%   -0.03%     
==========================================
  Files        1583     1583              
  Lines       96900    96948      +48     
  Branches    19831    19846      +15     
==========================================
+ Hits        52778    52784       +6     
- Misses      36647    36684      +37     
- Partials     7475     7480       +5     
Flag Coverage Δ
jsdom 49.96% <5.55%> (-0.02%) ⬇️
node 15.59% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@life2015 life2015 merged commit 52d6c29 into main Sep 19, 2024
@life2015 life2015 deleted the fix/dap-direct-adapter-and-terminal branch September 19, 2024 09:59
@opensumi
Copy link
Copy Markdown
Contributor

opensumi Bot commented Sep 19, 2024

🎉 PR Next publish successful!

3.3.4-next-1726743249.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants