🐛 retry once on connection error#468
Open
ianardee wants to merge 1 commit into
Open
Conversation
sebastianMindee
approved these changes
Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Hi Mindee Team,
We are using the Mindee Node.js SDK (
mindeeClient.enqueue()) in a Next.js / Vercel Serverless environment. We are consistently hitting anUND_ERR_SOCKET("other side closed") error on our API routes. Because Vercel pauses serverless execution between invocations, Keep-Alive sockets in the connection pool go stale. When the function wakes up for the next request, undici grabs a pooled socket that the Mindee API (or its load balancer) has already closed, resulting in an immediate crash atbytesWritten: 0.We have tried multiple aggressive workarounds to completely disable connection reuse and Keep-Alive, but the SDK seems to bypass or ignore them:
1. Using the SDK's
dispatcheroptionWe passed a custom undici Agent to strictly disable pipelining and keep-alive pools:
2. Monkey-patching
https.requestWe tried intercepting Node's underlying https module to force
keepAlive: false:3. Setting Environment Variables
We also added
MINDEE_REQUEST_TIMEOUT=60andNODE_TLS_REJECT_UNAUTHORIZED=0to our Vercel environment.Despite all of this, the SDK continues to grab closed sockets from a pool somewhere and fails.
Types of changes