kwhitley / itty-durable

Cloudflare Durable Objects + Itty Router = shorter code
MIT License
244 stars 18 forks source link

fix: parse response asynchronously #19

Closed Pom4H closed 1 year ago

Pom4H commented 2 years ago

From durable:

const another = proxyDurable(ANOTHER_DURABLE).get('default', { class: AnotherDurable, parse: true });
const result = await another.method(); // Returns successfully but with console.error:

[mf:err] Unhandled Promise Rejection: SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
    at Response.json (/node_modules/undici/lib/fetch/body.js:306:17)
    at runNextTicks (node:internal/process/task_queues:61:5)
    at processImmediate (node:internal/timers:437:9)
    at process.topLevelDomainCallback (node:domain:152:15)
    at process.callbackTrampoline (node:internal/async_hooks:128:24)

Good work! Working with durable objects is now much easier!