-
Notifications
You must be signed in to change notification settings - Fork 326
Closed
Description
Problem
The sql method in Agent uses console.error directly for logging SQL errors:
} catch (e) {
console.error(`failed to execute sql query: ${query}`, e);
throw this.onError(e);
}This bypasses any structured logging the application may have configured. During DO resets (e.g., code deployments), this produces unstructured logs like:
(error) failed to execute sql query:
INSERT OR REPLACE INTO cf_agents_state (id, state)
VALUES (?, ?)
Error: Durable Object reset because its code was updated.
Proposal
Allow users to customize logging behavior, either via:
- Override method -
onSqlError(query: string, error: unknown)that defaults toconsole.errorbut can be overridden - Logger injection - Accept a logger in Agent options/constructor
- Use observability - Route through the existing
observabilityinterface
Option 1 is minimal and consistent with existing patterns like onError.
Metadata
Metadata
Assignees
Labels
No labels