Each response has fields telling you if it's the primary or a replica handling your request and from

Each response has fields telling you if it's the primary or a replica handling your request and from which region: https://developers.cloudflare.com/d1/best-practices/read-replication/#check-where-d1-request-was-processed

const result = await env.DB.withSession()
  .prepare(`SELECT * FROM Customers WHERE CompanyName = 'Bs Beverages'`)
  .run();
console.log({
  servedByRegion: result.meta.served_by_region ?? "",
  servedByPrimary: result.meta.served_by_primary ?? "",
});
Was this page helpful?