workerd
workerd copied to clipboard
type D1Result problem
According to the documentation, the 'success' field under D1Result should be of type boolean, but currently, it is set to true. https://developers.cloudflare.com/d1/platform/client-api/#return-object
declare interface D1Result<T = unknown> {
results: T[];
success: true;
meta: any;
error?: never;
}
Hey! 👋 Thanks for reporting this. It looks like the D1 Worker API will always throw an error if success is false...
https://github.com/cloudflare/workerd/blob/8a06df3ee110e47cfc40e5b410f8805efdb61da6/src/cloudflare/internal/d1-api.ts#L116-L120
...so D1Results you see, will always have success: true set. @geelen, can you confirm the docs are incorrect here?
Hey all, I help maintain a D1 compatible database sdk, and I found this issue while trying to update my typing. Looks like the docs are right? Does that make this a bug?
The code looks wrong to me, return an error with plain text error message makes it hard for us to handle the different errors returned from D1.
I agree the doc is right and this should be mark as a bug.