LivePersonInc / node-agent-sdk

LivePerson Agent Messaging SDK for NodeJS
MIT License
49 stars 79 forks source link

Is `updateConversationField` a concurrently safe method? #115

Open lutsykigor opened 4 years ago

lutsykigor commented 4 years ago

We are currently using .updateConversationField method in our service to transfer a customer to another agent. Our service is a REST API that transfers a customer using a single instance of the LE Node.js bot.

Is it safe, after all? I mean, we are calling .updateConversationField like this:

this.updateConversationField({
                'conversationId': conversationId,
                'conversationField': [{
                    'field': 'ParticipantsChange',
                    'type': 'ADD',
                    'role': 'MANAGER'
                }]
            }, async (err, resp) => {
                this._handleTransportError(err);
                await asyncOperation1;
                await asyncOperation2;
            });

from our request handling logic. Which means, that we can initiate a call to.updateConversationField multiple times, without waiting for response, and then our callbacks are an async functions, that are, also, divided into multiple async phases.

Will node-agent-sdk handle this concurrent flow correctly? What are the best practice, of using this lib in race situations?