Skip to content

Commit c8c48a1

Browse files
authored
fix: fix install context is not right (#613)
1 parent 72288c3 commit c8c48a1

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

internal/service/install_plugin.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"time"
78

89
"github.com/gin-gonic/gin"
910
controlpanel "github.com/langgenius/dify-plugin-daemon/internal/core/control_panel"
@@ -116,13 +117,16 @@ func InstallMultiplePluginsToTenant(
116117

117118
for _, job := range jobs {
118119
jobCopy := job
120+
// create a detached context for async task to avoid http request cancellation
121+
taskCtx, taskCancel := context.WithTimeout(context.Background(), 15*time.Minute)
119122
// start a new goroutine to install the plugin
120123
routine.Submit(routinepkg.Labels{
121124
routinepkg.RoutineLabelKeyModule: "service",
122125
routinepkg.RoutineLabelKeyMethod: "InstallPlugin",
123126
}, func() {
127+
defer taskCancel()
124128
tasks.ProcessInstallJob(
125-
ctx,
129+
taskCtx,
126130
manager,
127131
tenants,
128132
runtimeType,

0 commit comments

Comments
 (0)