[PR #596] fix: use context.Background() for trace context in LaunchLocalPlugin #604

Open
opened 2026-02-16 01:16:29 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langgenius/dify-plugin-daemon/pull/596
Author: @maniknarang
Created: 2/4/2026
Status: 🔄 Open

Base: mainHead: manik/ctx-background


📝 Commits (1)

  • 75459a1 fix: use context.WithoutCancel(ctx) for trace context in LaunchLocalPlugin

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 internal/core/control_panel/launcher_local.go (+1 -1)

📄 Description

Description

Bug was introduced in PR #583

When plugins are installed via HTTP API, the request context passed to LaunchLocalPlugin gets stored via runtime.SetTraceContext(ctx). This context is cancelled when the HTTP response is sent, but environment initialization continues asynchronously. This causes exec.CommandContext to fail immediately with "context canceled" during dependency installation.

This fix changes SetTraceContext(ctx) to SetTraceContext(context.WithoutCancel(ctx)).

Before
Screenshot 2026-02-04 at 1 07 45 PM

After
Screenshot 2026-02-04 at 1 08 10 PM (2)

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Performance improvement
  • Other

Testing

  • I have tested the changes locally and confirmed they work as expected
  • I have added unit tests where necessary and they pass successfully

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langgenius/dify-plugin-daemon/pull/596 **Author:** [@maniknarang](https://github.com/maniknarang) **Created:** 2/4/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `manik/ctx-background` --- ### 📝 Commits (1) - [`75459a1`](https://github.com/langgenius/dify-plugin-daemon/commit/75459a133c22128e76749a8f0e2bae0d23f7c949) fix: use context.WithoutCancel(ctx) for trace context in LaunchLocalPlugin ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `internal/core/control_panel/launcher_local.go` (+1 -1) </details> ### 📄 Description ## Description Bug was introduced in PR #[583](https://github.com/langgenius/dify-plugin-daemon/pull/583) When plugins are installed via HTTP API, the request context passed to `LaunchLocalPlugin` gets stored via `runtime.SetTraceContext(ctx)`. This context is cancelled when the HTTP response is sent, but environment initialization continues asynchronously. This causes `exec.CommandContext` to fail immediately with "context canceled" during dependency installation. This fix changes `SetTraceContext(ctx)` to `SetTraceContext(context.WithoutCancel(ctx))`. **Before** <img width="562" height="344" alt="Screenshot 2026-02-04 at 1 07 45 PM" src="https://github.com/user-attachments/assets/b0e5335e-d95b-4c7b-9c3e-00e234dededa" /> **After** <img width="562" height="327" alt="Screenshot 2026-02-04 at 1 08 10 PM (2)" src="https://github.com/user-attachments/assets/cdc33d5c-a741-4b39-8141-d40f0ee30998" /> ## Type of Change - [x] Bug fix - [ ] New feature - [ ] Refactor - [ ] Performance improvement - [ ] Other ### Testing - [x] I have tested the changes locally and confirmed they work as expected - [x] I have added unit tests where necessary and they pass successfully --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 01:16:29 -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#604