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

🐛 Fix inflight/pending callbacks execute in wrong order #671

Merged
merged 2 commits into from
Jul 30, 2024

Conversation

benjismith
Copy link
Contributor

I encountered a situation in ShareDB where my callbacks are often executed in the wrong order.

I tracked this down to incorrect behavior in the doc.fetch() method, which pushes the inflightCallback onto the back of the callbacks array. If there are already any pendingCallbacks in the array, then the inflightCallback will be executed AFTER all the pendingCallbacks.

This is obviously not the desired behavior. The inflightCallback should always be executed FIRST, before any of the pendingCallbacks.

I fixed the code and wrote a test demonstrating the fix. If you remove my bugfix and run the test, you'll see that it reliably fails.

@alecgibson
Copy link
Collaborator

alecgibson commented Jul 22, 2024

Thanks for the submission! I've looked into the build failure; looks like it's an upstream Node.js issue 😬

Have run the tests (and linting) locally and it works fine for me.

@alecgibson
Copy link
Collaborator

Looks sensible, but will have a quick sense-check with @ericyhwang tomorrow

@benjismith
Copy link
Contributor Author

Any news?

@alecgibson
Copy link
Collaborator

@benjismith sorry our PR meeting last week was cancelled. @ericyhwang you around to discuss today? Or happy to take a look async?

@coveralls
Copy link

Coverage Status

coverage: 97.445%. remained the same
when pulling 7aa4f32 on benjismith:master
into 161d8b5 on share:master.

Copy link
Contributor

@ericyhwang ericyhwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, I was out last week. Makes sense to me.

@alecgibson alecgibson merged commit 296199b into share:master Jul 30, 2024
8 checks passed
@alecgibson
Copy link
Collaborator

@benjismith
Copy link
Contributor Author

Awesome, thank you!

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.

4 participants