{"record":{"id":"f7e559a3d05ad851","repo":"abhigyanpatwari/GitNexus","slug":"response-message-sidecar-embed-error","errorCode":null,"errorMessage":"response.message (sidecar embed error)","messagePattern":"response\\.message \\(sidecar embed error\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/embeddings/embedding-sidecar-client.ts","lineNumber":407,"sourceCode":"  if (localUnavailable) throw localUnavailableError();\n  if (ready && child) {\n    rejectConflictingForceDevice(options?.forceDevice);\n    return { device };\n  }\n\n  if (!ensureChain) {\n    const { signal: _ignored, ...initOptions } = options ?? {};\n    ensureChain = spawnAndInit(initOptions).finally(() => {\n      ensureChain = null;\n    });\n  }\n  await raceAbort(ensureChain, options?.signal);\n  rejectConflictingForceDevice(options?.forceDevice);\n  return { device };\n};\n\nconst vectorsFromEmbedResponse = (response: SidecarResponse): Float32Array[] => {\n  if (response.type === 'error') throw new Error(response.message);\n  if (response.type !== 'vectors') {\n    throw new Error(`Unexpected sidecar response: ${response.type}`);\n  }\n  return response.vectors.map((row) => Float32Array.from(row));\n};\n\nexport const sidecarEmbedBatch = async (\n  texts: string[],\n  options?: { signal?: AbortSignal },\n): Promise<Float32Array[]> => {\n  if (texts.length === 0) return [];\n  options?.signal?.throwIfAborted();\n  if (localUnavailable) throw localUnavailableError();\n\n  if (!ready || !child) {\n    await ensureEmbeddingSidecar({ signal: options?.signal });\n  }\n","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/core/embeddings/embedding-sidecar-client.ts#L389-L425","documentation":"vectorsFromEmbedResponse validates every reply from the sidecar's embed call. If the sidecar responds with type 'error' (it failed to compute embeddings for the batch), the sidecar's message is thrown as an Error. Any other non-'vectors' reply also throws with 'Unexpected sidecar response'.","triggerScenarios":"sidecarEmbedBatch() sends a batch to the running sidecar; the sidecar replies {type:'error', message} — e.g. batch rejected, model runtime error mid-inference, or the process degraded after init.","commonSituations":"Sending batches larger than the sidecar can process (OOM during inference), input text the tokenizer cannot handle, model corrupted after load, or protocol mismatch after a CLI/sidecar version skew (old sidecar binary with new client).","solutions":["Read the sidecar message for the per-batch failure cause and fix it (reduce batch size, fix inputs, reload model).","Retry the request with a smaller batch to rule out memory pressure during inference.","Confirm sidecar and client versions match; restart the sidecar so it and the client share one protocol.","If the sidecar is repeatedly failing, fall back to the HTTP embedding client."],"exampleFix":"// before: one large batch\nconst vectors = await sidecarEmbedBatch(allItems);\n// after: chunked embed with fallback\nconst vectors: Float32Array[] = [];\nfor (const chunk of chunked(allItems, 32)) {\n  vectors.push(...await sidecarEmbedBatch(chunk));\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  vectors = await sidecarEmbedBatch(batch);\n} catch (e) {\n  if (batch.length > 1) {\n    // retry smaller on sidecar embed error (likely memory/size related)\n    vectors = (await Promise.all(chunked(batch, Math.ceil(batch.length / 2)).map(sidecarEmbedBatch))).flat();\n  } else throw e;\n}","preventionTips":["Keep batch sizes modest (e.g. ≤64) to avoid OOM inside the sidecar.","Sanitize/normalize input text lengths before embedding.","Monitor sidecar health and restart it if repeated embed errors occur.","Keep client and sidecar binaries version-matched."],"tags":["embeddings","sidecar","ipc","batch"],"backgroundTag":"unexpected-response-shape","analyzedSha":"ac9a4e9abd8fd3058c070b72c23402a4f887929a","analyzedAt":"2026-09-15T23:29:44.066Z","contentChangedAt":"2026-09-15T23:29:44.066Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}