kwhitley / itty-durable

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

Possible error when not using proxydurable function to access class #13

Open janat08 opened 2 years ago

janat08 commented 2 years ago

I tested this a couple of weeks ago, so I don't remember if it's an issue. Simply accessing durable from request somehow fails, so you have to use the proxydurable export on environment variable for durable object binding.

ambirex commented 2 years ago

I think this might have something to do with itty-router because I noticed my own class (not DO) doesn't persist as an object; instead, I end up having to Object.assign(passedData, new MyClass())

I haven't wrapped my mind around all of the router's 30 some lines of code to figure out why that may be. (as in, I'm impressed with its brevity)

edit: sorry, didn't really the original close enough and sounded like something I found from the router.

janat08 commented 2 years ago

I think you’re writing about something else this is for when using do middlewear to bind classes to request, which returns undefined. I don’t think that assigning class to data is useful in a way that you think it is.

kwhitley commented 2 years ago

Definitely wouldn't/shouldn't be itty as the culprit (likely a break in my DO logic or perhaps a revision to how DO works in general, as this was developed shortly after they came out of beta last year)... but I need to dust this arm of development off anyway!

Thanks for the reminder - couple days of intense interviews this week, then I'll take a look and see if we can get this all sorted :)