-
Notifications
You must be signed in to change notification settings - Fork 10
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
Conversation
salesforce
Add support for asyncMode
in bulk operation
if (asyncMode) { | ||
return batch.on('queue', async function (batchInfo) { | ||
console.info('Batch queued. Batch ID:', batchInfo.id); | ||
resolve({ batchInfo }); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
@@ -66,6 +66,7 @@ import flatten from 'lodash/flatten'; | |||
* @property {boolean} [failOnError=false] - Fail the operation on error. | |||
* @property {integer} [pollTimeout=240000] - Polling timeout in milliseconds. | |||
* @property {integer} [pollInterval=6000] - Polling interval in milliseconds. | |||
* @property {boolean} [asynMode=false] - Use asyn mode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
@mtuchi where are we on this? I'm still not comfortable with this promise that returns multiple times. When you call In your code, every time the queue event is called, you're trying to resolve the promise again. There are two really important things here:
I can't merge this as-is, it's too unsafe. What we actually want to do is resolve the promise after the last queue event has triggered. But we have no way of knowing that, right? jsforce gives us no "queue finished event. See the issue for a possible solution, although I'm not totally sure I trust that either 🤔 |
Hiya @josephjclark i have forgotten to close this PR, from our last conversation we don't want this implementation and we agreed to put more effort on updating jsforce instead. |
Summary
Add
asyncMode
option in bulk operation. If you don't provided this extraasyncMode
option, we return all record info tostate.data
as we currently do.Fixes #286
Details
asyncMode
istrue
we returnbatchInfo
{ success: true, batches: [], errors: []}
ifasyncMode: true
state.data.batches
asyncMode: true
AI Usage
Please disclose how you've used AI in this work (it's cool, we just want to know!):
You can read more details in our Responsible AI Policy
Review Checklist
Before merging, the reviewer should check the following items:
dev only changes don't need a changeset.