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

Non deterministic order of promise resolution #110

Closed
dlespiau opened this issue Feb 4, 2019 · 0 comments · Fixed by #143
Closed

Non deterministic order of promise resolution #110

dlespiau opened this issue Feb 4, 2019 · 0 comments · Fixed by #143
Labels
Milestone

Comments

@dlespiau
Copy link
Member

dlespiau commented Feb 4, 2019

If we fire two std.read, jk will currently start two goroutines and the first goroutine to finish will signal the promise as resolved. It means promise resolve functions can be called in any order.

In turns, it opens many non-deterministic behaviour if the promise resolve functions act on a global state: mutate global or captured variables, call the random generator, ...

One possible way to make this a lot better is to resolve the promise in the order they came in. Ensuring the resolve functions are always called in the same order. This depends a bit on the v8 internals and on what happens when a promise is resolved. Need a bit more digging (and a test!)

dlespiau added a commit that referenced this issue Mar 5, 2019
We want the js author to be able to rely on deterministic order of promise
resolution to avoid surprises and generate non-determinitic configuration.

We do this by making the order of promise resolution be the same as promise
resolution, serializing the deferred goroutines before they re-enter v8 to
resolve the promises.

Fixes: #110
dlespiau added a commit that referenced this issue Mar 5, 2019
We want the js author to be able to rely on deterministic order of promise
resolution to avoid surprises and generate non-determinitic configuration.

We do this by making the order of promise resolution be the same as promise
resolution, serializing the deferred goroutines before they re-enter v8 to
resolve the promises.

Fixes: #110
dlespiau added a commit that referenced this issue Mar 5, 2019
We want the js author to be able to rely on deterministic order of promise
resolution to avoid surprises and generate non-determinitic configuration.

We do this by making the order of promise resolution be the same as promise
resolution, serializing the deferred goroutines before they re-enter v8 to
resolve the promises.

Fixes: #110
dlespiau added a commit that referenced this issue Mar 5, 2019
We want the js author to be able to rely on deterministic order of promise
resolution to avoid surprises and generate non-determinitic configuration.

We do this by making the order of promise resolution be the same as promise
resolution, serializing the deferred goroutines before they re-enter v8 to
resolve the promises.

Fixes: #110
dlespiau added a commit that referenced this issue Mar 5, 2019
We want the js author to be able to rely on deterministic order of promise
resolution to avoid surprises and generate non-determinitic configuration.

We do this by making the order of promise resolution be the same as promise
resolution, serializing the deferred goroutines before they re-enter v8 to
resolve the promises.

Fixes: #110
@dlespiau dlespiau added this to the 0.3.0 milestone Mar 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant