Skip to content
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

Silo: State corruption on error (And no error detection) #131

Open
Hexcede opened this issue Feb 14, 2023 · 1 comment
Open

Silo: State corruption on error (And no error detection) #131

Hexcede opened this issue Feb 14, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Hexcede
Copy link

Hexcede commented Feb 14, 2023

Currently, if an error occurs within a Silo the Silo will break permanently due to a flag getting set not being unset (Silo thinks a modifier is running forever). Additionally, there's currently no way to determine if a dispatched modifier actually succeeded or not, and there is no way to detect failures.

This can result in data corruption. Using Silos for currency in this broken state allows for code to make any, and as many changes, and those modifications will never apply. This is particularly problematic when used to keep track of currency.

Additionally, while modifications are atomic, reads are not. If modifiers are still processing (such as a modifier which removes currency) the state becomes dangerous to read.


I would propose:

  • :Dispatch returns and uses a Promise-like, so failures can be handled, and modifiers can be awaited.
  • Modifiers have the ability to return a Promise-like.
  • Silo provides a method to wait for processing modifiers to ensure atomicity (Effectively a Promise.all for all of the modifier promises)
@Sleitnick Sleitnick self-assigned this Feb 14, 2023
@Sleitnick Sleitnick added the bug Something isn't working label Feb 14, 2023
@Sleitnick
Copy link
Owner

Sleitnick commented Feb 14, 2023

The way redux solves this is by running the reducer (synonymous to modifiers in this case) in a try/finally block. That way, if the reducer fails, it is still able to mark itself as "done" to prevent it from hanging forever. Source.

So a possible solution without having to have promises is to just wrap the modifier call in pcall within Silo. For some reason, Redux has chosen not to add a catch clause and thus errors will probably be silent, but I'd at least like to output the error from the modifier call.

Ideally, modifiers should not yield either. I can check for that pretty easily and throw an error if it does yield.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants