Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(slack-notifications): [nan-1164] multiple notifications on refres…
…h error (#2433) ## Describe your changes This annoying issue is hard to reproduce without removing the locking delay on local for the `tryAcquire` method ``` const ttlInMs = 1; const acquisitionTimeoutMs = 1; const { tries } = await this.locking.tryAcquire(lockKey, ttlInMs, acquisitionTimeoutMs); ``` With that multiple slack notifications can be seen which in my testing was mitigated by: - Adding in transactions and `forUpdate` to the database lookups and inserts - Adding a slight randomized delay for webhook firing to prevent concurrent firing - `await` the slack notification call ## Testing - It seemed the customers issue was stemming from proxy calls and only with salesforce which is likely caused by the introspection call. So I tested with a script that made many concurrent proxy calls: ``` Promise.allSettled([ nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), nango.get({ providerConfigKey: "salesforce", connectionId: "sf-2", endpoint: `/services/data/v51.0/sobjects/Contacts/describe`, }), ``` With this I was seeing multiple slack notifications but with the update logic now only one is received consistently. ## Issue ticket number and link NAN-1163 ## Checklist before requesting a review (skip if just adding/editing APIs & templates) - [ ] I added tests, otherwise the reason is: - [ ] I added observability, otherwise the reason is: - [ ] I added analytics, otherwise the reason is:
- Loading branch information