-
Notifications
You must be signed in to change notification settings - Fork 14
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
When object returned by 'use' is mutated before, 'try' returns. Hence comparison is sabotaged. #10
Comments
The general solution I can think of is to have the
As I wrote these points out, it feels like this is a more consistent async-mode behavior, but definitely not possible to bake in until a major version bump. I'm thinking we can go with a flag for now and roll it in if it still feels right. |
Would this be something where Object.assign() would be beneficial? Prior to invocation the incoming arguments could be "cloned" to address this. This would mean a performance delay there, but I'm not sure the impact. |
I don't think so. The library has no way to see incoming values – only the result values produced by the behaviors. We still can't naively clone those because, well, cloning is hard in JavaScript. The result might be (or contain) an array, a date, or an object with a non-trivial prototype chain. I think the best solution is to just make guarantees for the user instead of allowing them to introduce a race condition. |
Is anybody still maintaining this project? |
If subj is not enough:
we have 'use' and 'try' functions returning promises (so, async = true). I'll call these funcs as main and secondary.
There is Function consumer that uses main. I am introducing parallel call, so now consumer uses result of science() call.
Consumer mutates object A after promise from main is resolved. But secondary hasn't been resolved yet.
Secondary is resolved with object B and scientist grabs it to compare with A (which at this point has been mutated already). Result is - false positive mismatch.
We currently solve it by cloning deep object A on the way from science().
I thought you might be interested in making some general solution since our scenario seems quite real.
The text was updated successfully, but these errors were encountered: