SalesforceCommerceCloud / b2c-crm-sync

... a contemporary perspective on how to integrate B2C Commerce and the Salesforce Customer 360 Platform to power frictionless customer experiences in the B2C domain.
https://salesforcecommercecloud.github.io/b2c-crm-sync/
BSD 3-Clause "New" or "Revised" License
65 stars 46 forks source link

[BUG] Latest version of the connector causes System.CalloutException #249

Open ddxxtony opened 1 year ago

ddxxtony commented 1 year ago

Describe the bug If we use the latest version of the connector and a profile is created or updated from the storefront, we will encounter an error in the B2CCommerce_PlatformEvent_ProcessContactUpdate flow (see error below).

Debug the failed interview in Flow Builder for the interview GUID: 661641cf990704fd776128f0b240189308e9be1-2a0d Error element ia_retrieveB2CCommerceCustomerProfile (FlowActionCall). An Apex error occurred: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

To Reproduce Steps to reproduce the behavior: First Issue

  1. Go to storefront
  2. Create a profile
  3. You will receive an email notifying you that there was an error with this flow: B2CCommerce_PlatformEvent_ProcessContactUpdate.

Second Issue(same issue with different steps)

  1. Go to storefront
  2. Access your account
  3. Update any information.
  4. You will receive an email notifying you that there was an error with this flow: B2CCommerce_PlatformEvent_ProcessContactUpdate.

Expected behavior We should not receive any errors when a user signs in or signs up on the storefront.

Screenshots image image

Your local environment details:

Your remote environment details:

Additional context It seems like the maintainers have been trying to fix this issue for a long time. Initially, they solved it by adding pauses to the B2CContactProcess Flow, but this resulted in another error where SFCC wasn't receiving all the necessary information (Error Related to AccountID ). As a result, they removed the pause elements, which led to the reoccurrence of this issue.

Possible solution I moved the event publishing in the B2CContactProcess flow to the end and added a pause element before it. The only issue with this change is that the flow status returned to SFCC is 'waiting', but it doesn't cause any problems. Apart from that, I haven't found any major issues. If you see any caveats, please let me know.

This fix solves the problem for this bug and the other bugs reported #163, #106, #115 . image

jbachelet commented 1 year ago

Hello,

Thanks for raising the issue. Yes, I've been trying to solve this and reverted the change with the Pause element as it resulted in the fact that the flow was not returning to SFCC the AccountId and ContactId, which SFCC stores and reuses afterward. Thus, this technical solution is not suitable here, and the only way to fix this from my POV is to rework the whole logic executed here.

This is a pending work in progress that I need to address, but no ETA so far