# Action button's script time out issue

**URL:** <https://community.fibery.io/t/action-buttons-script-time-out-issue/2018>\
**Category:** Get Help\
**Created:** [September 15, 2021, 7:38am UTC](https://community.fibery.io/t/action-buttons-script-time-out-issue/2018 "2021-09-15T07:38:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Niraj\_Chourasia](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/niraj_chourasia/32/4084_2.png) [@Niraj\_Chourasia](https://community.fibery.io/u/Niraj_Chourasia)\
**Post date:** [September 15, 2021, 7:38am UTC](https://community.fibery.io/t/action-buttons-script-time-out-issue/2018/1 "2021-09-15T07:38:02Z")

</div>

Hi there,  
We are facing script time out issue. We are using script to call an external api and after success response updating the entity but some times script giving error of time out. please help me or suggest me solution for that.

---

<div class="post-metadata">

**Author:** ![Oleg](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/oleg/32/1887_2.png) [@Oleg](https://community.fibery.io/u/Oleg)\
**Post date:** [September 15, 2021, 3:39pm UTC](https://community.fibery.io/t/action-buttons-script-time-out-issue/2018/2 "2021-09-15T15:39:40Z")

</div>

Hi, @Niraj_Chourasia

Thanks for letting us know about the issue. Looks like the problem is in time response of external api over HTTP. I will check our request timeout settings in order to increase it if possible. In meantime, could you please also share your code without any credentials, auth or sensitive information? Probably we will figure out the way to optimise it.

Will keep you informed.

Thanks,  
Oleg

---

<div class="post-metadata">

**Author:** ![Niraj\_Chourasia](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/niraj_chourasia/32/4084_2.png) [@Niraj\_Chourasia](https://community.fibery.io/u/Niraj_Chourasia)\
**Post date:** [September 16, 2021, 7:23am UTC](https://community.fibery.io/t/action-buttons-script-time-out-issue/2018/3 "2021-09-16T07:23:09Z")

</div>

Hi Oleg,  
Thanks for reply and looking into this matter. here is the code that we are using

## script code start

// Fibery API is used to retrieve and update entities  
const fibery = context.getService(‘fibery’);

// affected entities are stored in args.currentEntities;  
// to support batch actions they always come in an array  
for (var entity of args.currentEntities) {  
// an entity contains all fields apart from collections;  
// to access a field refer to it by its UI name  
var creationDate = entity[‘Creation Date’];  
var Name = entity[‘Name’];  
var EntityId = entity[‘id’];  
var Type = entity[‘Type’];  
// to get collection fields query the API and provide the list of fields  
// const entityWithExtraFields = await fibery.getEntityById(entity.type, entity.id, [‘Assignees’, ‘Files’]);  
}

const http = context.getService(‘http’);  
const filename = `${new Date().toISOString().slice(0, 10)}-${Name }.pdf`;

var formationDate = new Date();  
formationDate.setDate(formationDate.getDate() + 1);  
const monthNames = [“January”, “February”, “March”, “April”, “May”, “June”,  
“July”, “August”, “September”, “October”, “November”, “December”  
];  
creationDate = `${monthNames[formationDate.getUTCMonth()]} ${formationDate.getDate()}, ${formationDate.getUTCFullYear()}`;

const response = await http.postAsync(‘[https://connect.pabbly.com/workflow/sendwebhookdata/xxxxxx\_3D](https://connect.pabbly.com/workflow/sendwebhookdata/xxxxxx_3D)’, {  
body: { creationDate , Name, EntityId },  
headers: { ‘Content-type’: ‘application/json’ }  
});

let document = JSON.parse(response);  
//uploadd file to entity  
await fibery.addFileFromUrl(  
document[2].pdfUrl,  
filename,  
Type,  
EntityId,  
null  
);

Hope you will find it and suggest solution.

---

<div class="post-metadata">

**Author:** ![Oleg](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/oleg/32/1887_2.png) [@Oleg](https://community.fibery.io/u/Oleg)\
**Post date:** [September 16, 2021, 3:09pm UTC](https://community.fibery.io/t/action-buttons-script-time-out-issue/2018/4 "2021-09-16T15:09:39Z")

</div>

Hi, @Niraj_Chourasia

Thanks for the code. It helps a lot. We increased timeout for file for url action and improved file uploading. Please let me know if the issue still can be reproduced.

Thanks,  
Oleg
