-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: cloudflare-sqlite for durable objects #787
base: main
Are you sure you want to change the base?
Conversation
Very nice! A bit bogged down but will look next week after the holiday. |
@mattzcarey great to see this come through! Can you please add this to the tests in the |
Hey @benjamincburns, not sure how I can do that since the sqlite api doesnt really exist outside of durable objects. I'll see if I can get someone for them CF team to help. |
I'm going to try and take a look at this |
@threepointone LMK if you have any questions! |
start:node: 3, | ||
node: 3 | ||
}, | ||
versions_seen: { | ||
__input__: {}, | ||
__start__: { | ||
__start__: 1 | ||
}, | ||
node: { | ||
start:node: 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed invalid JSON
start:node: 3, | |
node: 3 | |
}, | |
versions_seen: { | |
__input__: {}, | |
__start__: { | |
__start__: 1 | |
}, | |
node: { | |
start:node: 2 | |
"start:node": 3, | |
node: 3 | |
}, | |
versions_seen: { | |
__input__: {}, | |
__start__: { | |
__start__: 1 | |
}, | |
node: { | |
"start:node": 2 |
const pendingWrites = await Promise.all( | ||
(() => { | ||
try { | ||
return JSON.parse(String(row.pending_writes || '[]')) as PendingWriteColumn[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of the stringification and parsing that requires the type assertion? Is there a way to add a type guard to ensure the structure of row.pending_writes
rather than forcing it?
const pending_sends = await Promise.all( | ||
(() => { | ||
try { | ||
return JSON.parse(String(row.pending_sends || '[]')) as PendingSendColumn[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.error('Failed to parse pending writes:', e); | ||
return []; | ||
} | ||
})().map(async (write) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This IIFE is a little hard to read, would you be able to separate the promise resolution from the iterations?
console.error('Failed to parse pending sends:', e); | ||
return []; | ||
} | ||
})().map(async (send) => await this.serde.loadsTyped(send.type ?? 'json', send.value ?? '')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cloudflare durable objects have a slightly different sqlite api.
Tests are not passing cause I am getting some weird esm errors, but this works for me in a durable object.
Have a great weekend,
Matt