Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hung when I use denops.dispatch("", "") #415

Open
kamecha opened this issue Sep 3, 2024 · 5 comments
Open

hung when I use denops.dispatch("", "") #415

kamecha opened this issue Sep 3, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@kamecha
Copy link

kamecha commented Sep 3, 2024

Describe the bug

hung when I fire :call denops#request("hoge", "hung_dispatch") that denops plugin's dispatch

Provide a minimal vimrc with less than 50 lines to reproduce

denops plugin which has denops.dispatch("", "")

to reproduce this behavior you have to make simple denops plugin.
make directory like bellow.

.
└── denops
    └── test
        └── main.ts

main.ts

import type { Entrypoint } from "jsr:@denops/[email protected]";

export const main: Entrypoint = (denops) => {
  denops.dispatcher = {
    dispatch_none: async () => {
      await denops.dispatch("", "");
    },
  };
};

.vimrc

set rtp+=~/path/to/vim-denops/denops.vim
set rtp+=~/path/to/above/directory

How to reproduce the problem from Vim startup

  1. type :call denops#request("test", "dispatch_none", [])
  2. hung

Expected behavior

denops return something like error, and I can operate vim after firing dispatch.

Actual behavior

after firing the dispatch I can't operate vim ( hung ).

Screenshots (if need)

Your environment

  • OS: uname -a (macOS/Linux) or ver (Windows)
    Linux DESKTOP 5.15.90.1-microsoft-standard-WSL2+ #2 SMP Thu Aug 31 01:45:54 JST 2023 x86_64 x86_64 x86_64 GNU/Linux

  • Deno version: deno --version
    deno 1.46.1 (stable, release, x86_64-unknown-linux-gnu)
    v8 12.9.202.2-rusty
    typescript 5.5.2

  • Vim/Neovim version: vim --version or nvim --version
    NVIM v0.11.0-dev-408+gb1aa8f5eb
    Build type: RelWithDebInfo
    LuaJIT 2.1.1720049189

  • Denops version: git log -1 (run in the denops.vim repository)
    commit f32f028 (HEAD -> main, origin/main, origin/HEAD)
    Merge: 45b8a1c 604b394
    Author: Λlisue
    Date: Fri Aug 30 08:16:33 2024 +0900

    Merge pull request 👍 no package json #414 from vim-denops/no-package-json

    👍 no package json

Additional context

@kamecha kamecha added the bug Something isn't working label Sep 3, 2024
@lambdalisue
Copy link
Member

Actually, it's spec. denops.dispatch() waits the specified plugin.

async dispatch(
name: string,
fn: string,
...args: unknown[]
): Promise<unknown> {
await this.#service.waitLoaded(name);
return await this.#service.dispatch(name, fn, args);
}
}

However, I think there are several unwilling behaviors

  1. "" should not be a valid plugin name
  2. There should be a way to skip this wait
  3. There should be an easy way to specify timeout for denops.dispatch
  4. Ctrl-c should interrupt this wait so that Vim wan't freeze

I'll consider aboves

@lambdalisue lambdalisue self-assigned this Sep 3, 2024
@lambdalisue lambdalisue pinned this issue Sep 3, 2024
@lambdalisue lambdalisue removed their assignment Sep 3, 2024
@kamecha
Copy link
Author

kamecha commented Sep 3, 2024

I found this behavior when I'm setting the denops plugin that contains denops.dispatch("otherPlugin", "hoge").
I think that the user who doesn't plugin developer and doesn't install the "otherPlugin" want to know "otherPlugin" name.

So I want to know the plugin name feedback

@kamecha
Copy link
Author

kamecha commented Sep 4, 2024

wait really?
If so, I think timeout doesn't work.

wait_timeout is set 30000→1000
https://github.com/user-attachments/assets/3b03bd98-d5c0-432c-828b-bd0851f09b61

@Milly
Copy link
Contributor

Milly commented Sep 13, 2024

wait really? If so, I think timeout doesn't work.

wait_timeout is set 30000→1000 https://github.com/user-attachments/assets/3b03bd98-d5c0-432c-828b-bd0851f09b61

denops#server#wait_timeout and denops#plugin#wait_timeout are not relevant to this issue.
They are only options to the Vim methods (for now).

*g:denops#server#wait_timeout*
	Timeout in milliseconds for |denops#server#wait()|.
	Default: 30000

						*denops#server#wait()*
denops#server#wait([{options}])
	Waits synchronously until a |DenopsReady| autocmd is fired. It returns
	immediately when the autocmd is already fired.
	It returns -1 if it times out, -2 if the server is not started or
	interrupted.
	Developers need to consider this return value to decide whether to
	continue with the subsequent process.
	The following attributes are available on {options}.

        "interval"	Interval in milliseconds for |:sleep| in internal
        		loop.
			Default: |g:denops#server#wait_interval|
	"timeout"	Timeout in milliseconds to block.
			Default: |g:denops#server#wait_timeout|
	"silent"	1 to silence error messages.
			Default: 0

*g:denops#plugin#wait_timeout*
	Timeout in milliseconds for |denops#plugin#wait()|.
	Default: 30000

						*denops#plugin#wait()*
denops#plugin#wait({name}[, {options}])
	Waits synchronously until a {name} plugin is loaded or failed to load.
	It returns immediately when the {name} plugin is already loaded. It
	throws an error when {name} does not match the |denops-plugin-name|.

	Developers need to consider the following return value to decide
	whether to continue with the subsequent process:

	 0	The {name} plugin is loaded successfully.
	-1	"timeout" expired.
	-2	The server is not yet ready or interrupted.
	-3	The {name} plugin failed to load.

	The following attributes are available on {options}.

        "interval"	Interval in milliseconds for |:sleep| in internal
        		loop.
			Default: |g:denops#plugin#wait_interval|
	"timeout"	Timeout in milliseconds to block.
			Default: |g:denops#plugin#wait_timeout|
	"silent"	1 to silence error messages.
			Default: 0

@Milly
Copy link
Contributor

Milly commented Sep 16, 2024

  • "" should not be a valid plugin name
  • There should be a way to skip this wait
  • There should be an easy way to specify timeout for denops.dispatch
  • Ctrl-c should interrupt this wait so that Vim wan't freeze

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

No branches or pull requests

3 participants