{"record":{"id":"fd7a6ddb6faf4172","repo":"FlowiseAI/Flowise","slug":"error-in-llm-node-error-instanceof-error-erro","errorCode":null,"errorMessage":"Error in LLM node: ${error instanceof Error ? error.message : String(error)}","messagePattern":"Error in LLM node: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/agentflow/LLM/LLM.ts","lineNumber":694,"sourceCode":"                        name: nodeData?.label ? nodeData?.label.toLowerCase().replace(/\\s/g, '_').trim() : nodeData?.id,\n                        ...(((artifacts && artifacts.length > 0) || (fileAnnotations && fileAnnotations.length > 0)) && {\n                            additional_kwargs: {\n                                ...(artifacts && artifacts.length > 0 && { artifacts }),\n                                ...(fileAnnotations && fileAnnotations.length > 0 && { fileAnnotations })\n                            }\n                        })\n                    }\n                ]\n            }\n        } catch (error) {\n            if (options.analyticHandlers && llmIds) {\n                await options.analyticHandlers.onLLMError(llmIds, error instanceof Error ? error.message : String(error))\n            }\n\n            if (error instanceof Error && error.message === 'Aborted') {\n                throw error\n            }\n            throw new Error(`Error in LLM node: ${error instanceof Error ? error.message : String(error)}`)\n        }\n    }\n\n    /**\n     * Handles memory management based on the specified memory type\n     */\n    private async handleMemory({\n        messages,\n        memoryType,\n        pastChatHistory,\n        runtimeChatHistory,\n        llmNodeInstance,\n        nodeData,\n        userMessage,\n        input,\n        abortController,\n        options,\n        modelConfig","sourceCodeStart":676,"sourceCodeEnd":712,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/agentflow/LLM/LLM.ts#L676-L712","documentation":"The catch-all at the end of LLM_Agentflow.run(). Any exception not matching the special-case 'Aborted' (user-initiated abort, which is re-thrown verbatim) is wrapped as `Error in LLM node: <message>`. The analytics onLLMError handler is invoked first with the raw message. This wrapper preserves the original message text but replaces the error type and stack origin.","triggerScenarios":"The chat model throws (auth failure, rate limit, context-length exceeded, invalid model name), memory/vector-store retrieval fails, a structured-output schema is invalid, or the provider SDK raises any non-Abort error.","commonSituations":"Wrong/missing API key for the provider; model name typo or deprecated model; prompt+history exceeds token limit; tool/structured-output JSON schema mismatch; transient provider 5xx.","solutions":["Read the analytics dashboard (onLLMError fires) or server logs for the inner message after the colon.","If the message mentions auth/key — fix the model credential.","If it mentions tokens/context — trim chat history or reduce input size.","If it mentions model not found — correct the model name in the model component.","For transient provider errors, add retry at the provider/flow level.","Patch the wrapper to use `{ cause: error }` so the original stack survives."],"exampleFix":"// before\n            throw new Error(`Error in LLM node: ${error instanceof Error ? error.message : String(error)}`)\n// after\n            throw new Error(`Error in LLM node: ${error instanceof Error ? error.message : String(error)}`, { cause: error })","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await llmNode.run(nodeData, input, options)\n} catch (e) {\n  const msg = (e as Error).message\n  if (msg === 'Aborted') return // user-initiated, swallow\n  if (msg.startsWith('Error in LLM node: ')) {\n    const inner = msg.slice('Error in LLM node: '.length)\n    // branch on inner: auth, context length, model not found\n  }\n  throw e\n}","preventionTips":["Pre-validate provider credentials and model name before the LLM node.","Bound chat history length to avoid context-overflow errors.","Subscribe to onLLMError analytics to capture the raw inner message.","Pass a stable AbortController so aborts are intentional."],"tags":["agentflow","llm","error-wrapping","provider","analytics"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}