{"record":{"id":"9014eef64ebf6865","repo":"FlowiseAI/Flowise","slug":"error-saving-checkpoint","errorCode":null,"errorMessage":"Error saving checkpoint","messagePattern":"Error saving checkpoint","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/memory/AgentMemory/MySQLAgentMemory/mysqlSaver.ts","lineNumber":191,"sourceCode":"            const queryRunner = dataSource.createQueryRunner()\n            const row = [\n                config.configurable?.thread_id || this.threadId,\n                checkpoint.id,\n                config.configurable?.checkpoint_id,\n                Buffer.from(this.serde.stringify(checkpoint)), // Encode to binary\n                Buffer.from(this.serde.stringify(metadata)) // Encode to binary\n            ]\n            const tableName = this.sanitizeTableName(this.tableName)\n\n            const query = `INSERT INTO ${tableName} (thread_id, checkpoint_id, parent_id, checkpoint, metadata)\n                           VALUES (?, ?, ?, ?, ?)\n                           ON DUPLICATE KEY UPDATE checkpoint = VALUES(checkpoint), metadata = VALUES(metadata)`\n\n            await queryRunner.manager.query(query, row)\n            await queryRunner.release()\n        } catch (error) {\n            console.error('Error saving checkpoint', error)\n            throw new Error('Error saving checkpoint')\n        } finally {\n            await dataSource.destroy()\n        }\n\n        return {\n            configurable: {\n                thread_id: config.configurable?.thread_id || this.threadId,\n                checkpoint_id: checkpoint.id\n            }\n        }\n    }\n\n    async delete(threadId: string): Promise<void> {\n        if (!threadId) return\n\n        const dataSource = await this.getDataSource()\n        await this.setup(dataSource)\n        const tableName = this.sanitizeTableName(this.tableName)","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/memory/AgentMemory/MySQLAgentMemory/mysqlSaver.ts#L173-L209","documentation":"MySQLSaver.put wraps the INSERT ... ON DUPLICATE KEY UPDATE; any DB or serde.stringify error is logged via console.error and re-thrown generically. The connection is destroyed in finally.","triggerScenarios":"checkpoint/metadata payload too large for the BLOB / max_allowed_packet; serde.stringify throws on a non-serializable checkpoint; connection lost mid-write; PK conflict edge cases.","commonSituations":"Very large graph state exceeding MySQL packet size; non-serializable value in checkpoint metadata; flaky connection during a write; concurrent writes racing on the same checkpoint_id.","solutions":["Check console logs to distinguish a serde failure from a DB failure.","Raise max_allowed_packet on the MySQL server if payloads are large.","Ensure checkpoint/metadata are serializable (no functions, circular refs, BigInt).","Verify connection stability and INSERT/UPDATE privileges."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-serialise to fail before hitting the DB on non-serializable state\nfunction assertSerializable(value: unknown): void {\n  structuredClone(value) // throws on non-cloneable (functions, etc.)\n  JSON.stringify(value)   // throws on circular refs\n}","typeGuard":null,"tryCatchPattern":"try {\n  await saver.put(config, checkpoint, metadata)\n} catch (e) {\n  if (/Error saving checkpoint/.test((e as Error).message)) {\n    // inspect logs: serde vs DB; raise max_allowed_packet if payload too large\n  }\n  throw e\n}","preventionTips":["Keep checkpoint state JSON-serializable (no functions, BigInt, circular refs).","Raise max_allowed_packet for large graph states.","Verify INSERT/UPDATE privileges and connection stability.","Log the original error from console.error to triage quickly."],"tags":["mysql","agent-memory","database","query","insert","memory"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}