vim-denops / denops.vim

🐜 An ecosystem of Vim/Neovim which allows developers to write cross-platform plugins in Deno
https://vim-denops.github.io/denops-documentation/
MIT License
666 stars 33 forks source link

:+1: Async server start stop #378

Closed Milly closed 2 months ago

Milly commented 2 months ago

Summary by CodeRabbit

coderabbitai[bot] commented 2 months ago

[!IMPORTANT]

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This update enhances the Denops plugin by introducing robust error handling, improved channel management, and streamlined server behaviors. Key changes include adding error callbacks, refining connection retries, enhancing server start and stop mechanisms, and expanding test utilities. These modifications aim for better reliability, consistency in server operations, and improved test coverage.

Changes

Files Change Summary
autoload/denops/_internal/job.vim Added error handling for job execution, adjusted callbacks to receive job objects.
autoload/denops/_internal/server/chan.vim Replaced for loop with while for retries, added timeout for channel close, new force close functions.
autoload/denops/_internal/server/proc.vim Simplified server startup, removed retry logic, updated autocmd event names.
autoload/denops/server.vim Added new status constants and functions for server management, introduced new variables for server state management.
denops/@denops-private/host.ts Added close() method to Service interface, updated invoke() function.
denops/.../host/nvim_test.ts Updated function parameters to object destructuring, added close method to Service.
denops/.../host/vim_test.ts Similar updates as nvim_test.ts, added close method to service.
denops/.../host_test.ts Introduced close method in the service object, added corresponding test cases.
denops/.../testutil/host.ts Added stdout and stderr parameters to HostFn and TestFn, updated related functions.
denops/.../testutil/shared_server.ts Modified to handle stderr, added new channels for stdout and stderr.
denops/.../shared_server_test.ts Added new assertions and conditions for verbose output handling, new tests for verbose scenarios.
denops/.../shared_server_test_no_verbose.ts Introduced new file with test scenarios involving a brief delay.
denops/.../shared_server_test_verbose_true.ts Introduced new file with test scenarios for verbose flag set to true.
denops/.../with.ts Enhanced stream and process communication, updated command execution, improved error handling and cleanup.
denops/.../worker.ts Updated command in connectHost to trigger DenopsSystemReady autocmd event.
denops/.../worker_test.ts Updated doautocmd function parameter to DenopsSystemReady in multiple instances.
doc/denops.txt Updated descriptions for restart thresholds, reconnect intervals, close timeout settings, and server functions.
tests/.../plugin_test.ts Updated function definitions for object destructuring of the host parameter.
tests/.../server_test.ts Improved test logic, asynchronous handling, error messages, and status transitions for server operations.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DenopsPlugin
    participant Job
    participant ServerChan
    participant ServerProc
    participant TestUtil
    User->>DenopsPlugin: Initialize
    DenopsPlugin->>ServerProc: Start server
    ServerProc->>ServerChan: Establish connection
    ServerChan->>DenopsPlugin: Connection established
    User->>DenopsPlugin: Run Command
    DenopsPlugin->>Job: Execute job
    Job->>DenopsPlugin: Job result
    User->>DenopsPlugin: Stop server
    DenopsPlugin->>ServerProc: Shutdown server
    ServerProc->>ServerChan: Close channels
    ServerChan->>TestUtil: Cleanup

Poem

Amidst the code in Vim's delightful land,
Denops evolves with error handling grand.
Channels close with grace, no time to wait,
Jobs will run, never check too late.
Servers start and stop, reconnect anew,
In tests we trust, the bugs we now subdue.
Celebrate with hops, our journey never ends,
For each line of code, a rabbit-send depends.

  (\(\   
 ( -.-)  
o_(")(") 🍂

[!TIP]

Early access features: disabled We are currently testing the following features in early access: - **OpenAI `gpt-4o` model for code reviews and chat**: OpenAI claims that this model is better at understanding and generating code than the previous models. We seek your feedback over the next few weeks before making it generally available. Note: - You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file. - Please join our [Discord Community](https://discord.com/invite/GsXnASn26c) to provide feedback and report issues.

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.
codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 87.34177% with 10 lines in your changes missing coverage. Please review.

Project coverage is 92.30%. Comparing base (dd6ca3c) to head (f766e94).

Files Patch % Lines
denops/@denops-private/testutil/with.ts 82.92% 7 Missing :warning:
denops/@denops-private/testutil/host.ts 60.00% 2 Missing :warning:
denops/@denops-private/testutil/shared_server.ts 96.15% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## v7-pre #378 +/- ## ========================================== - Coverage 92.51% 92.30% -0.22% ========================================== Files 21 21 Lines 1242 1286 +44 Branches 142 142 ========================================== + Hits 1149 1187 +38 - Misses 90 96 +6 Partials 3 3 ```

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

Milly commented 2 months ago

I committed 👍 remove retry_interval, retry_threshold from proc#start() to make it easier to see the diff, and after review I want to amend it to 👍 change denops#server#start and ...#stop to asynchronous because it breaks tests.

Milly commented 2 months ago

@coderabbitai review

coderabbitai[bot] commented 2 months ago
Actions performed Review triggered. > Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
coderabbitai[bot] commented 2 months ago

[!NOTE] Currently processing new changes in this PR. This may take a few minutes, please wait...

Commits Files that changed from the base of the PR and between dd6ca3c4f851f279aac9efd51199f49d7088934b and 5e7e3c26eb8b2d05dae9850811f401da5396d63f.
Files selected for processing (19) * autoload/denops/_internal/job.vim (3 hunks) * autoload/denops/_internal/server/chan.vim (4 hunks) * autoload/denops/_internal/server/proc.vim (6 hunks) * autoload/denops/server.vim (4 hunks) * denops/@denops-private/host.ts (3 hunks) * denops/@denops-private/host/nvim_test.ts (1 hunks) * denops/@denops-private/host/vim_test.ts (1 hunks) * denops/@denops-private/host_test.ts (2 hunks) * denops/@denops-private/testutil/host.ts (3 hunks) * denops/@denops-private/testutil/shared_server.ts (3 hunks) * denops/@denops-private/testutil/shared_server_test.ts (1 hunks) * denops/@denops-private/testutil/shared_server_test_no_verbose.ts (1 hunks) * denops/@denops-private/testutil/shared_server_test_verbose_true.ts (1 hunks) * denops/@denops-private/testutil/with.ts (4 hunks) * denops/@denops-private/worker.ts (1 hunks) * denops/@denops-private/worker_test.ts (7 hunks) * doc/denops.txt (5 hunks) * tests/denops/plugin_test.ts (3 hunks) * tests/denops/server_test.ts (4 hunks)
 ___________________________
< Debugging like it's 2099. >
 ---------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).

[!TIP]

Early access features: enabled We are currently testing the following features in early access: - **OpenAI `gpt-4o` model for code reviews and chat**: OpenAI claims that this model is better at understanding and generating code than the previous models. We seek your feedback over the next few weeks before making it generally available. Note: - You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file. - Please join our [Discord Community](https://discord.com/invite/GsXnASn26c) to provide feedback and report issues. - OSS projects are always opted into early access features.

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.
lambdalisue commented 2 months ago

@Milly ~It seems the status is still draft. Let me know when the PR become ready (I already reviewed in case)~

and after review I want to amend it to 👍 change denops#server#start and ...#stop to asynchronous because it breaks tests.

Got it. Let me know when rebased @Milly

Milly commented 2 months ago

I rebased it. @lambdalisue