router-for-me/CLIProxyAPI · error
allocate plugin response buffer: %w
Error message
allocate plugin response buffer: %w
What it means
Before invoking the Windows plugin call pointer, the host allocates a windowsBuffer via LocalAlloc to receive the response. If LocalAlloc returns an error (wrapped here), the call cannot proceed. This is a local memory-allocation failure, not a plugin failure.
Source
Thrown at internal/pluginhost/loader_windows.go:277
case <-ctx.Done():
return nil, ctx.Err()
default:
}
}
methodBytes, errMethod := syscall.BytePtrFromString(method)
if errMethod != nil {
return nil, errMethod
}
var requestPtr uintptr
if len(request) > 0 {
requestPtr = uintptr(unsafe.Pointer(&request[0]))
}
responseMem, errAlloc := windows.LocalAlloc(
windows.LMEM_FIXED|windows.LMEM_ZEROINIT,
uint32(unsafe.Sizeof(windowsBuffer{})),
)
if errAlloc != nil {
return nil, fmt.Errorf("allocate plugin response buffer: %w", errAlloc)
}
if responseMem == 0 {
return nil, fmt.Errorf("allocate plugin response buffer")
}
defer func() {
_, _ = windows.LocalFree(windows.Handle(responseMem))
}()
response := (*windowsBuffer)(unsafe.Pointer(responseMem))
rc, _, _ := syscall.SyscallN(
c.api.call,
uintptr(unsafe.Pointer(methodBytes)),
requestPtr,
uintptr(len(request)),
responseMem,
)
var out []byte
if response.ptr != 0 && response.len > 0 {
out = unsafe.Slice((*byte)(unsafe.Pointer(response.ptr)), response.len)View on GitHub (pinned to 78f0c4079e)
Solutions
- Reduce memory pressure: lower concurrency, restart the process, or raise the container/job memory limit
- Rate-limit concurrent plugin calls so response-buffer allocations stay bounded
- Capture the wrapped error code to confirm it is allocation-related before deeper debugging
Defensive patterns
Strategy: retry
Try / catch
out, err := client.Call(ctx, method, body)
if err != nil && strings.Contains(err.Error(), "allocate plugin response buffer") {
// transient memory pressure: shed load and retry once
time.Sleep(50 * time.Millisecond)
out, err = client.Call(ctx, method, body)
} Prevention
- Cap concurrent plugin calls with a semaphore
- Monitor process memory and restart on sustained growth
- Run with adequate container memory limits
When it happens
Trigger: Extreme process memory pressure causing LocalAlloc to fail; handle/memory quota exhaustion; extremely large numbers of concurrent plugin calls each allocating response buffers.
Common situations: Host process near its memory limit (many plugins + heavy traffic); running under a job object or container with a tight memory cap.
Related errors
- allocate plugin response buffer
- cliproxy_plugin_init returned %d: %v
- plugin ABI version %d is not supported
- plugin function table is incomplete
- remove stale shadow plugin: %w
AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15).
Data as JSON: /api/errors/689ce49d89105076.
Report an issue: GitHub.