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

salesforce Add support for asyncMode in bulk operation #907

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

mtuchi
Copy link
Collaborator

@mtuchi mtuchi commented Jan 14, 2025

Summary

Add asyncMode option in bulk operation. If you don't provided this extra asyncMode option, we return all record info to state.data as we currently do.

Fixes #286

Details

  • If asyncMode is true we return batchInfo
  • Formatted the results to { success: true, batches: [], errors: []} if asyncMode: true
  • Add docs for state.data.batches
  • Add integration test when asyncMode: true

AI Usage

Please disclose how you've used AI in this work (it's cool, we just want to know!):

  • Code generation (copilot but not intellisense)
  • Learning or fact checking
  • Strategy / design
  • Optimisation / refactoring
  • Translation / spellchecking / doc gen
  • Other
  • I have not used AI

You can read more details in our Responsible AI Policy

Review Checklist

Before merging, the reviewer should check the following items:

  • Does the PR do what it claims to do?
  • If this is a new adaptor, added the adaptor on marketing website ?
  • Are there any unit tests?
  • Is there a changeset associated with this PR? Should there be? Note that
    dev only changes don't need a changeset.
  • Have you ticked a box under AI Usage?

@mtuchi mtuchi linked an issue Jan 14, 2025 that may be closed by this pull request
@mtuchi mtuchi changed the title 286 asyncmode salesforce Add support for asyncMode in bulk operation Jan 14, 2025
@mtuchi mtuchi marked this pull request as ready for review January 14, 2025 14:39
@mtuchi mtuchi requested a review from josephjclark January 14, 2025 14:39
if (asyncMode) {
return batch.on('queue', async function (batchInfo) {
console.info('Batch queued. Batch ID:', batchInfo.id);
resolve({ batchInfo });
Copy link
Collaborator

Choose a reason for hiding this comment

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

A promise can only resolve once. If there are multiple queue events, for multiple chunks, then they'll never report back to user code. In other words, we'll only ever report back the first batch here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

🤔 I have tried running the test with a batch size of 1 and i got the expected results.
Can you tell me more about this ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have tested multiple batches by reducing the batch size to 1 and run integration test that insert two records with the option asynMode: true, I can see that i am getting two batches records after the bulk operation is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New Issues
Development

Successfully merging this pull request may close these issues.

Add option to salesforce for asyncMode: true/false on bulk(...)
2 participants