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(persister): Handle concurrent find requests #88

Merged
merged 1 commit into from
Aug 8, 2018

Conversation

offirgolan
Copy link
Collaborator

No description provided.

@offirgolan offirgolan requested a review from jasonmit August 8, 2018 05:55
it('should handle concurrent find requests', async function() {
await Promise.all([
this.persister.find('test'),
this.persister.find('test'),
Copy link
Contributor

@jasonmit jasonmit Aug 8, 2018

Choose a reason for hiding this comment

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

Can we update the test to assert when adding another recordingId that it will increment?

i.e.:

this.persister.find('foo');
this.persister.find('foo');
this.persister.find('bar ');
/* count 2 */

Can you also add tests where a mutation, like delete, is done in between finds. Feels like a possible race condition. After this change, the second find would return the result of the first - correct? Which would not be valid. Since it was really deleted. In either case, we should add tests around this and patch any bugs. . You already added tests in the file previously that covers this :)

const { _cache: cache } = this;

if (!cache.has(recordingId)) {
const findRecording = async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth naming this anonymous fn for a better callstack

@jasonmit jasonmit merged commit 0e02414 into master Aug 8, 2018
@jasonmit jasonmit deleted the concurrent-persister-finds branch August 8, 2018 23:36
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.

2 participants