How to prevent UrlFetchApp.fetch from going on forever? [duplicate]
This post was edited and submitted for review 6 hours ago.
First of all let me clarify that I have read the answers of the similar questions
Lower the timeout for urlFetchApp.fetch function and Timeout Error - DHL API to Google Sheets 开发者_JAVA百科- UrlFetchApp
but this question is different. Here I'm asking why UrlFetchApp.fetch and UrlFetchApp.fetchAll are blocking the script execution entirely (never return response) until you get an "Exceeded maximum execution time" error. It happens occasionally for some URLs like the one at the example shown bellow
function fetch_test() {
const res = UrlFetchApp.fetch('https://www.usnews.com/news/world/articles/2022-12-06/turkey-again-threatens-greece-for-arming-aegean-islands')
}
You will notice that fetch never ends until you get an "Exceeded maximum execution time" error. It happens to fetch and fetchAll but I can't figure out why. How can I prevent/handle this situation?
精彩评论