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

Deterministic promise resolution #143

Merged
merged 3 commits into from
Mar 6, 2019

Conversation

dlespiau
Copy link
Member

@dlespiau dlespiau commented 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 creation, serializing the deferred goroutines before they re-enter v8 to resolve the promises.

Fixes: #110

@dlespiau dlespiau force-pushed the 2019-03-05-deterministic-promise-resolution branch 2 times, most recently from 1d5c6b0 to 937534b Compare March 5, 2019 17:43
dlespiau added 2 commits March 5, 2019 17:48
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 force-pushed the 2019-03-05-deterministic-promise-resolution branch from 937534b to 80dabb3 Compare March 5, 2019 17:49
@squaremo
Copy link
Member

squaremo commented Mar 6, 2019

Elegant.

We the info capturing i in the loop works (because of the block scoping from
let), we can refine a bit the test, also removing the unnecessary encoding
argument to std.read.

I tested it with a previous version of jk and the test still shows the "random"
behaviour.
@dlespiau dlespiau merged commit c674536 into master Mar 6, 2019
@dlespiau dlespiau deleted the 2019-03-05-deterministic-promise-resolution branch March 6, 2019 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Non deterministic order of promise resolution
2 participants