Is there any way to start workers that would be guaranteed to be co-located with a specific durable object? This way they would have ultrafast access to the state it manages but not subject to the single-thread limitation.
I in particular like the output gates, I really like that way of handling transaction durability, where you do all the work, but external side-effects are only triggered when the transaction successfully commits. That, combined with the caching makes it really powerful.
There is a case for input gates, I didn't completely follow at first, and I think it might be worth adding as an example to the article.
What happens if I do:
At first I thought this would deadlock, until I looked into the proper description for the input gates:
Any other events will be deferred until such a time as the object is no longer executing JavaScript code and is no longer waiting for any storage operations.
In particular, the "until such a time as the object is no longer executing JavaScript code" - in that case, we would not be running any code, and just return the result of the fetch.
If you have two requests doing this, then you may end up with races again.
It's akin to your later example with two concurrent storage operations, but in this case there is only one read.