cookie-cutter icon indicating copy to clipboard operation
cookie-cutter copied to clipboard

Dispatch Context State Get, with null or undefined returns all streams?

Open cross311 opened this issue 4 years ago • 1 comments

I want to check that if a null or undefined is passed into ctx.state.get(undefined), does it return all streams? I know this is a feature, but it seems really dangerous. I had an event that i read the stream id off of, and i was worried it might have been null due to getting an OOM error. turns out it was not it, but i want to do my due diligence to make sure if null or undefined gets passed in an error is thrown to remove that as a possibility.

Also the state.get() getting all streams seems dangerous as well, should it not be state.all()? or something more deliberate or easier to find?

cross311 avatar Jun 19 '20 17:06 cross311

you MUST provide a key to ctx.state.get(...), it will not return all streams if you pass null. there is ctx.state.compute() which optionally takes a key. that one synchronously computes the what-if state if all the events your stored were applied to the base state. it will only do that for states you already loaded in that event handler though.

sklose avatar Jun 19 '20 17:06 sklose