Remote plugin debugging: Skip 5-second sleep delay for faster development iteration #154

Closed
opened 2026-02-16 00:20:11 -05:00 by yindo · 0 comments
Owner

Originally created by @Blackoutta on GitHub (Jul 4, 2025).

Self Checks

To make sure we get to you in time, please check the following :)

  • [Y] I have searched for existing issues search for existing issues, including closed ones.
  • [Y] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [Y] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • [Y] "Please do not modify this template :) and fill in all the required fields."

Versions

  1. dify-plugin-daemon 0.1.3
  2. dify-api 1.5.1

Describe the bug
When debugging a plugin remotely, if you immediately restart the plugin after closing it with CTRL+C (this is actually a common operation when manually modifying code and restarting the plugin), the plugin will be unable to reconnect properly, causing the page to report an error: "no available node, plugin not found."

The cause of this issue is: the time.sleep in internal/core/plugin_manager/lifecycle/full_duplex.go

I understand this 5-second sleep is to prevent the plugin exit-restart process from being too fast, which could cause excessive resource consumption, but this creates a poor experience during DEBUGGING, as developers typically need to quickly close and restart plugins manually during debugging.

internal/core/plugin_manager/lifecycle/full_duplex.go

   for !r.Stopped() {
   	// start plugin
   	if err := r.StartPlugin(); err != nil {
   		if r.Stopped() {
   			// plugin has been stopped, exit
   			break
   		}
   	}

   	// wait for plugin to stop normally
   	c, err := r.Wait()
   	if err == nil {
   		<-c
   	}

   	// restart plugin in 5s  
   	time.Sleep(5 * time.Second)   <==== this line caused the problem

   	// add restart times
   	r.AddRestarts()
   }

To Reproduce
Steps to reproduce the behavior:

  1. Connect the plugin to remote
  2. CTRL+C to close and immediately restart the plugin

As shown in the gif below:
Image

Expected behavior
When debugging plugins, quickly closing and restarting the plugin should not cause the error: "no available node, plugin not found."
I have prepared a pull request that checks whether it's a remote runtime at the time.sleep point, and only executes time.sleep if it's not remote runtime.
The execution effect is as follows:
Image
Code modification:
internal/core/plugin_manager/lifecycle/full_duplex.go

	for !r.Stopped() {
		// start plugin
		if err := r.StartPlugin(); err != nil {
			if r.Stopped() {
				// plugin has been stopped, exit
				break
			}
		}

		// wait for plugin to stop normally
		c, err := r.Wait()
		if err == nil {
			<-c
		}

		// restart plugin in 5s (skip for debugging runtime)
		if r.Type() != plugin_entities.PLUGIN_RUNTIME_TYPE_REMOTE {  <====changed here
			time.Sleep(5 * time.Second)
		}

		// add restart times
		r.AddRestarts()
	}

Screenshots
See above.

Additional context
None

Originally created by @Blackoutta on GitHub (Jul 4, 2025). **Self Checks** To make sure we get to you in time, please check the following :) - [Y] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify-plugin-daemon/issues), including closed ones. - [Y] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [Y] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [Y] "Please do not modify this template :) and fill in all the required fields." **Versions** 1. dify-plugin-daemon 0.1.3 2. dify-api 1.5.1 **Describe the bug** When debugging a plugin remotely, if you immediately restart the plugin after closing it with CTRL+C (this is actually a common operation when manually modifying code and restarting the plugin), the plugin will be unable to reconnect properly, causing the page to report an error: "no available node, plugin not found." The cause of this issue is: the time.sleep in internal/core/plugin_manager/lifecycle/full_duplex.go I understand this 5-second sleep is to prevent the plugin exit-restart process from being too fast, which could cause excessive resource consumption, but this creates a poor experience during DEBUGGING, as developers typically need to quickly close and restart plugins manually during debugging. internal/core/plugin_manager/lifecycle/full_duplex.go ``` for !r.Stopped() { // start plugin if err := r.StartPlugin(); err != nil { if r.Stopped() { // plugin has been stopped, exit break } } // wait for plugin to stop normally c, err := r.Wait() if err == nil { <-c } // restart plugin in 5s time.Sleep(5 * time.Second) <==== this line caused the problem // add restart times r.AddRestarts() } ``` **To Reproduce** Steps to reproduce the behavior: 1. Connect the plugin to remote 2. CTRL+C to close and immediately restart the plugin As shown in the gif below: ![Image](https://github.com/user-attachments/assets/fadefe8d-3826-4f1b-8699-8be76345458e) **Expected behavior** When debugging plugins, quickly closing and restarting the plugin should not cause the error: "no available node, plugin not found." I have prepared a pull request that checks whether it's a remote runtime at the time.sleep point, and only executes time.sleep if it's not remote runtime. The execution effect is as follows: ![Image](https://github.com/user-attachments/assets/024ff057-4fc1-4932-8396-b7dd8fa7758b) Code modification: internal/core/plugin_manager/lifecycle/full_duplex.go ``` for !r.Stopped() { // start plugin if err := r.StartPlugin(); err != nil { if r.Stopped() { // plugin has been stopped, exit break } } // wait for plugin to stop normally c, err := r.Wait() if err == nil { <-c } // restart plugin in 5s (skip for debugging runtime) if r.Type() != plugin_entities.PLUGIN_RUNTIME_TYPE_REMOTE { <====changed here time.Sleep(5 * time.Second) } // add restart times r.AddRestarts() } ``` **Screenshots** See above. **Additional context** None
yindo closed this issue 2026-02-16 00:20:11 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-plugin-daemon#154