{"record":{"id":"56d0676d95a2dedc","repo":"abhigyanpatwari/GitNexus","slug":"response-message-sidecar-init-error","errorCode":null,"errorMessage":"response.message (sidecar init error)","messagePattern":"response\\.message \\(sidecar init error\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/embeddings/embedding-sidecar-client.ts","lineNumber":333,"sourceCode":"\n  const persisted = {\n    embeddingConfig: options?.embeddingConfig ?? lastInitOptions?.embeddingConfig,\n    forceDevice: options?.forceDevice ?? lastInitOptions?.forceDevice,\n  };\n\n  child = spawnSidecar();\n  attachChild(child);\n  progressSink = options?.onProgress;\n  try {\n    const response = await request(\n      {\n        type: 'init',\n        embeddingConfig: persisted.embeddingConfig,\n        forceDevice: persisted.forceDevice,\n      },\n      sidecarInitTimeoutMs(),\n    );\n    if (response.type === 'error') throw new Error(response.message);\n    if (response.type !== 'ready') {\n      throw new Error(`Unexpected sidecar response: ${response.type}`);\n    }\n    ready = true;\n    device = response.device;\n    lastInitOptions = persisted;\n  } catch (err) {\n    reapEmbeddingSidecar();\n    throw err;\n  } finally {\n    progressSink = undefined;\n  }\n};\n\nconst rejectConflictingForceDevice = (forceDevice?: EmbeddingSidecarDevice): void => {\n  if (forceDevice && forceDevice !== device) {\n    throw new Error(\n      `Embedding sidecar already initialized on ${device}; cannot switch to ${forceDevice}`,","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/core/embeddings/embedding-sidecar-client.ts#L315-L351","documentation":"After spawning the sidecar, spawnAndInit sends an 'init' message with the persisted embedding config and waits for a 'ready' reply. If the sidecar replies with type 'error', the error message from the sidecar process is re-thrown as an Error here. It means the sidecar process itself failed to initialize its embedding runtime or model.","triggerScenarios":"ensureEmbeddingSidecar() → spawnAndInit() sends {type:'init', embeddingConfig, forceDevice}; the sidecar responds {type:'error', message} within sidecarInitTimeoutMs(); the message is thrown verbatim.","commonSituations":"Invalid or unsupported embedding model name/path in the persisted config; forceDevice naming a GPU that does not exist or lacks drivers; model download failure; corrupt model files; out-of-memory during model load.","solutions":["Read the sidecar message — it identifies the init failure (model load, device selection, config validation) and fix that underlying cause.","Clear or correct the persisted embedding config / forceDevice so init uses defaults (CPU, valid model).","Verify the model files exist and are complete; re-download or point embeddingConfig at a valid local model path.","Check GPU drivers/VRAM if a non-CPU device was forced; retry with forceDevice removed.","Increase the init timeout if the model is large and load legitimately exceeds sidecarInitTimeoutMs()."],"exampleFix":"// before: forcing a device that may not exist\npersistEmbeddingOptions({ forceDevice: 'gpu', embeddingConfig: cfg });\nawait ensureEmbeddingSidecar();\n// after: let the sidecar pick a valid device\npersistEmbeddingOptions({ forceDevice: undefined, embeddingConfig: validatedCfg });\nawait ensureEmbeddingSidecar();","handlingStrategy":"try-catch","validationCode":"// validate persisted options before init\nconst ok = persisted && typeof persisted.embeddingConfig?.model === 'string' &&\n  (!persisted.forceDevice || ['cpu', 'gpu'].includes(persisted.forceDevice));\nif (!ok) resetPersistedEmbeddingOptions();","typeGuard":null,"tryCatchPattern":"try {\n  await ensureEmbeddingSidecar();\n} catch (e) {\n  // sidecar init error: inspect e.message (model/device/config), reset options, retry once\n  resetPersistedEmbeddingOptions();\n  await ensureEmbeddingSidecar();\n}","preventionTips":["Validate model name/path and forceDevice in the persisted config before first init.","Only force a device you have verified exists (query available devices first).","Keep sidecar and CLI versions in lockstep.","Pre-warm the sidecar at startup so init failures surface early, not mid-job."],"tags":["embeddings","sidecar","init","model-load"],"backgroundTag":"module-init-failed","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"}