Custom functions in Google Sheets are occasionally stuck on 'Loading...' indefinitely

This question pertains specifically to the latest version of Google Sheets. Users have reported a recurring problem with custom functions created using Google Apps Script where certain cells show a persistent ‘Loading…’ message, often enveloped in a red error box. Although Google recommends refreshing the page or updating the function names across references to resolve this issue, many developers still encounter this persistent loading error. In my following answer, I outline several strategies I’ve discovered that help mitigate this problem, albeit with some constraints.

Sometimes the issue might be related to the complexity of your custom function or the amount of data being processed. If your script is calling external APIs or functions that take longer than a typical execution, it could lead to timeouts. Try optimizing your script for better performance, such as reducing unnecessary loops or breaking down the operation into smaller tasks. Another thing to consider is checking your browser’s console for any error messages that might give you additional clues on what’s causing the problem.

Another potential culprit could be your internet connection. Ensure you have a stable and speedy connection, as Google Sheets operates in a cloud environment and relies heavily on your network speed. When connections are slow or unstable, calls to execute custom functions might hang or timeout, leading to that ‘Loading…’ message. Additionally, try clearing your browser’s cache. Sometimes cached data can cause peculiar behavior or interfere with script execution. Running your script in a new Chrome incognito window can help determine if cached data might be part of the issue.

Check if there’s any issue with authorization permissions in your Google Apps Script. Sometimes functions require access privileges, and if not granted, it can freeze execution. Just reauthorize the script or check the permissions to see if that’s causing a delay. Hope it helps you out! :crossed_fingers: