Skip to content

Commit 6b7172d

Browse files
NeatGuyCodingNeatGuyCoding
andauthored
fix: errChan failed to write response because of panic nil (#296) (#297)
* fix: errChan failed to write response because of panic nil (#296) * fix: join err and er into a single error using errors.Join, thanks @Yeuoly (#296) --------- Co-authored-by: NeatGuyCoding <cto@sb>
1 parent b6906f7 commit 6b7172d

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

internal/core/plugin_manager/install_to_local.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package plugin_manager
33
import (
44
"time"
55

6+
"errors"
67
"github.com/langgenius/dify-plugin-daemon/internal/utils/log"
78
"github.com/langgenius/dify-plugin-daemon/internal/utils/routine"
89
"github.com/langgenius/dify-plugin-daemon/internal/utils/stream"
@@ -63,16 +64,24 @@ func (p *PluginManager) InstallToLocal(
6364
case err := <-errChan:
6465
if err != nil {
6566
// if error occurs, delete the plugin from local and stop the plugin
66-
identity, err := runtime.Identity()
67-
if err != nil {
68-
log.Error("get plugin identity failed: %s", err.Error())
67+
identity, er := runtime.Identity()
68+
if er != nil {
69+
log.Error("get plugin identity failed: %s", er.Error())
6970
}
70-
if err := p.installedBucket.Delete(identity); err != nil {
71-
log.Error("delete plugin from local failed: %s", err.Error())
71+
if er := p.installedBucket.Delete(identity); er != nil {
72+
log.Error("delete plugin from local failed: %s", er.Error())
7273
}
74+
75+
var errorMsg string
76+
if er != nil {
77+
errorMsg = errors.Join(err, er).Error()
78+
} else {
79+
errorMsg = err.Error()
80+
}
81+
7382
response.Write(PluginInstallResponse{
7483
Event: PluginInstallEventError,
75-
Data: err.Error(),
84+
Data: errorMsg,
7685
})
7786
runtime.Stop()
7887
return

0 commit comments

Comments
 (0)