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

INT-3404 - Add tests to validate behavior of jobState.hasKey #694

Merged
merged 5 commits into from
Apr 21, 2022

Conversation

austinkelleher
Copy link
Contributor

The Qualys integration was using awaiting the result of jobState.hasKey
and firing off multiple promises with pQueue.
The Qualys integration was occasionally seeing DUPLICATE_KEY_DETECTED
errors being thrown despite checking whether the graph object _key
exists before adding the new entity to the jobState. These tests were
added as part of the investigation into the issue.

The Qualys integration fix can be found here: JupiterOne-Archives/graph-qualys#190

The Qualys integration was using `await`ing the result of `jobState.hasKey`
and firing off multiple promises with [`pQueue`](https://github.com/sindresorhus/p-queue).
The Qualys integration was occasionally seeing `DUPLICATE_KEY_DETECTED`
errors being thrown despite checking whether the graph object `_key`
exists before adding the new entity to the `jobState`. These tests were
added as part of the investigation into the issue.

The Qualys integration fix can be found here: JupiterOne-Archives/graph-qualys#190
The Qualys integration was using `await`ing the result of `jobState.hasKey`
and firing off multiple promises with [`pQueue`](https://github.com/sindresorhus/p-queue).
The Qualys integration was occasionally seeing `DUPLICATE_KEY_DETECTED`
errors being thrown despite checking whether the graph object `_key`
exists before adding the new entity to the `jobState`. These tests were
added as part of the investigation into the issue.

The Qualys integration fix can be found here: JupiterOne-Archives/graph-qualys#190
ceelias
ceelias previously approved these changes Apr 21, 2022
// the `hasKey` promise while handling multiple entities concurrently,
// could result in a `hasKey` returning `false` because neither of the
// duplicate entities have been fully added to the job state yet.
if (jobState.hasKey(e._key)) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems to me that the documentation here

hasKey: (_key: string | undefined) => boolean | Promise<boolean>;
should change to provide reasons for why both sync and async forms are present, and when to use which.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Can tackle separately. Will open ticket. Thanks for suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

3 participants