-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Nullify batchRequestId immediatelly #92
Conversation
Sometimes the library threw unhandledException that parseParams is undefined in parseResponse.js:312 It happens because a single requestId is assigned to two different requests, and after the first one is done, the info for second request is deleted. A single requestId is assigned because of the batch implementation. After executeBatch function, the global _batchRequestId is not nulled, so any further request will get the same requestId, until executeBatch promise is not finished.
@Kukunin thank you for the PR, I will need to run some tests and/or write new ones before I can publish this. But I can see that the issue you are describing can happen. The only thing I want to check if this fix does not break anything else. Also the same fix needs to be done for the callbacks version. |
Sounds great. I'm not sure if it's related, but after the deployment of the fixed version, another problem started occurring:
for some reason, Before I dive deep into the bug, just wanted to share this with you. maybe you have any clue Thank you |
it seems like this exception happens if UPD: I can confirm, it happens on const api = new DynamicsWebApi(dynamicsOpts)
api.startBatch()
api.executeBatch() I've fixed it in my app's code to not start batch, but I believe it'd be good if a library can handle this case too |
at _convertToBatch dynamics-web-api/lib/requests/sendRequest.js:117:40 The problem happens because we nullify _batchRequestId too early, before the batch request is made. With _batchRequestId it generates a new requestId, other than all operations were saved to, thus it crashes
@AleksandrRogov it turned out, that with the first fix all batch requests were broken. I described the reason in the second commit. But the previous problem remain the same - it still crashes on empty batches |
Thank you @Kukunin for looking further into the issue. I am not sure what should I do with the 2nd issue, because I am not completely sure why would anyone send an empty batch request. I would still return an error but a more meaningful one, saying that the batch is empty. Developers need to check their request collections or any arrays that they use to build a batch first, before starting executing a batch operation. Let me know if you have another case that will show that the error should not be thrown and that I just need to add a code that would simply skip the operation. |
… before batch is completed; added a meaningful error message when the batch payload is empty #92
Thank you for packaging and merging my PR, appreciate it. The solution for empty batches makes total sense for me. |
Sometimes the library threw unhandledException
that parseParams is undefined in parseResponse.js:312
It happens because a single requestId is assigned to two different
requests, and after the first one is done, the info for the second request
is deleted.
A single requestId is assigned because of the batch implementation.
After executeBatch function, the global _batchRequestId is not nulled,
so any further request will get the same requestId, until executeBatch
promise is not finished.
I didn't find to write a test for this in a meaningful manner of time. Nor I found an existing test that is sensitive to this moment.