denops.vim icon indicating copy to clipboard operation
denops.vim copied to clipboard

:+1: Add plugin unload features

Open Milly opened this issue 1 year ago • 8 comments

This closes #332.

Plugin API

  • Entrypoint can now return AsyncDisposable.
  • The promise returned by Service.waitLoaded() will be rejected for the following reason string:
    • DenopsPluginFail:{name} when the plugin loading failed.
    • DenopsClosed when the service closed.

Vim API

  • Add new denops-variable:
    • g:denops#server#stop_timeout
    • g:denops#server#close_timeout
  • Add new denops-function:
    • denops#plugin#unload({plugin}[, {options}])
  • Add new state for denops#server#status():
    • closing
  • Add new events:
    • DenopsPluginFail:{plugin}
    • DenopsPluginUnloadPre:{plugin}
    • DenopsPluginUnloadPost:{plugin}
    • DenopsPluginUnloadFail:{plugin}
  • Behaviour changed denops-function:
    • denops#server#start() can now be called even when status is closing. In that case, the status will become stopped and then restart asynchronously.
    • denops#server#stop() is changed to asynchronously. It waits for the server to close gracefully, and force terminate if timeouted.
    • denops#server#restart() is changed to asynchronously. Perform the stop and start steps above.

Server

  • Trap SIGINT and notify service to close. If the worker is not stopped within the fixed timeout period, it will be terminated.
  • Patches in console.* fallback to true console output. It does not throw an exception if the call to Host fails.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a new Denops plugin module with teardown logic.
    • Enhanced service management with asynchronous disposal and improved error handling.
    • Added functionality to wait for specific system signals in Deno.
  • Bug Fixes

    • Improved handling of plugin loading and unloading failures.
  • Refactor

    • Transitioned to asynchronous methods in service and plugin classes for better performance and reliability.
  • Documentation

    • Updated method signatures and class interfaces to reflect asynchronous operations.
  • Tests

    • Expanded test coverage to include new error handling and event emission behaviors during plugin operations.

Milly avatar Apr 29 '24 18:04 Milly

[!IMPORTANT]

Auto Review Skipped

Auto reviews are disabled on base/target branches other than the default branch. Please add the base/target branch pattern to the list of additional branches to be reviewed in the settings.

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

The recent updates across the Denops project introduce enhancements in plugin lifecycle management, particularly focusing on asynchronous disposal and signal handling. These changes facilitate better resource management and error handling, aligning with modern asynchronous programming patterns in Deno.

Changes

File Path Change Summary
denops/@denops-private/cli.ts Added process signal import and modified promise management.
denops/@denops-private/plugin.ts, denops/@denops-private/process.ts Introduced new modules for plugin definitions and process signal handling.
denops/@denops-private/service.ts, denops/@denops-private/service_test.ts Upgraded Service class to AsyncDisposable, improved error handling and testing.
denops/@denops-private/testdata/... Added test plugins with valid and invalid teardown logic.
denops/@denops-private/worker.ts Enhanced signal handling and service initialization.

Assessment against linked issues

Objective Addressed Explanation
Add a way to clean up (teardown) a plugin (#332)

Poem

🐰✨ In the land of code, where the bits align,
A rabbit hopped, through the files so fine.
With a twitch of nose, and a flick of ear,
It crafted code, with nary a fear.
🌟 "To manage, to mend, to make anew,
Let's celebrate, for our bugs are few!" 🎉
So cheers to changes, both big and small,
In Denops' world, we hop through it all! 🐾


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>.
    • 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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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 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.

coderabbitai[bot] avatar Apr 29 '24 18:04 coderabbitai[bot]

I want to define the following interface as public. So that plugin developers can access it. denops/@denops-private/plugin.ts

Milly avatar Apr 29 '24 18:04 Milly

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 92.36%. Comparing base (cd83f94) to head (02cf5eb).

Additional details and impacted files
@@            Coverage Diff             @@
##           v7-pre     #335      +/-   ##
==========================================
+ Coverage   90.50%   92.36%   +1.85%     
==========================================
  Files           9        9              
  Lines         632      720      +88     
  Branches       61       83      +22     
==========================================
+ Hits          572      665      +93     
+ Misses         60       55       -5     

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

codecov[bot] avatar Apr 29 '24 18:04 codecov[bot]

@coderabbitai review

Milly avatar Apr 30 '24 06:04 Milly

@Milly Let me know when you finish Entrypoint with Disposable/AsyncDisposable

lambdalisue avatar May 03 '24 07:05 lambdalisue

@coderabbitai review

Milly avatar May 16 '24 01:05 Milly

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] avatar May 16 '24 01:05 coderabbitai[bot]

Too large patch. Split into small PR.

Milly avatar May 16 '24 11:05 Milly

Moved to #385

Milly avatar Jul 05 '24 12:07 Milly