mirror of
https://github.com/langgenius/dify-official-plugins.git
synced 2026-07-21 17:45:23 -04:00
[PR #1152] [MERGED] fix(vertex-ai): switch to REST transport to fix concurrency hang #1740
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/langgenius/dify-official-plugins/pull/1152
Author: @adrianfinantyo
Created: 6/24/2025
Status: ✅ Merged
Merged: 6/24/2025
Merged by: @crazywoola
Base:
main← Head:main📝 Commits (1)
2ba7e7cfix(vertex-ai): switch to REST transport to fix concurrency hang📊 Changes
4 files changed (+7 additions, -10 deletions)
View changed files
📝
models/vertex_ai/main.py(+0 -3)📝
models/vertex_ai/manifest.yaml(+1 -1)📝
models/vertex_ai/models/llm/llm.py(+2 -2)📝
models/vertex_ai/models/text_embedding/text_embedding.py(+4 -4)📄 Description
Related Issues or Context
This PR fixes an issue where the Vertex AI plugin hangs during document ingestion when handling multiple tasks. The problem was caused by gRPC transport not working well with the Gevent-based runtime. Switching to REST transport solves the issue.
Root Cause: gRPC transport hangs under concurrency due to incompatibility with Gevent.
Fix: Use REST transport in the Vertex AI SDK.
Root Cause (5 Whys)
It was waiting for responses from the Python plugin runtime, which never completed the embedding tasks.
The Python plugin runtime got stuck during the first call to Vertex AI SDK’s embedding method.
The SDK used gRPC, which isn’t compatible with the Gevent/greenlets concurrency model.
The runtime used
grpc.experimental.gevent.init_gevent()which causes silent hangs under load.Heartbeat ran in a separate thread and continued normally, masking the deadlock.
Ingestion Process
Task Execution Details
Start → Task starts in greenlet → Call Vertex AI SDK → SDK makes gRPC call → Monkey-patched gRPC triggers C-core call →
[Decision] Is gRPC call non-blocking? → ❌ No → gRPC performs blocking I/O → Greenlet does not yield → Event loop frozen
[Decision] Does gRPC need callback or IO to finish? → ✅ Yes → Needs scheduler to run → 🧨 Deadlock - circular wait
Fixing Approach: Use Vertex AI REST Transport
Result: With REST transport, concurrent embedding tasks complete successfully.
Related GitHub Issues
Closes #1132
This PR contains Changes to Non-Plugin
This PR contains Changes to Non-LLM Models Plugin
📷 Tested locally under concurrent embedding load. Plugin no longer hangs.
This PR contains Changes to LLM Models Plugin
📷 Before: plugin hangs after first request. After: runs normally with multiple concurrent tasks.
Version Control (Any Changes to the Plugin Will Require Bumping the Version)
manifest.yamlto0.0.22Dify Plugin SDK Version
dify_plugin>=0.3.0,<0.4.0is in requirements.txtEnvironment Verification (If Any Code Changes)
Local Deployment Environment
Tested locally with clean setup. Plugin runs with REST transport and handles concurrent tasks correctly.
SaaS Environment
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.