Skip to main content

Problem

The error “ Unable to complete Lua script compilation. The script may be blocked by operations in the global scope (e.g., database connections, network calls, or other functions that can hang). Please move any potentially blocking operations inside functions (for example, inside main() or an initialization function) so the component can start correctly. The duration of the compile-time timeout can be adjusted by setting the COMPONENT_COMPILE_TIMEOUT_SECONDS environment variable." indicates that the Lua script failed to compile in a timely manner.

Cause

Lua code outside of main gets executed once as part of the compile task. If the time it takes to compile exceeds the timeout value, this error occurs.

This was added in 10.1.116 to prevent components from hanging indefinitely on compilation which cannot be force killed.

Solution

By default, the compile-time timeout value is 60 seconds. To adjust the duration of this value, navigate to Settings → Environment and click “CREATE” to create a new environment variable, “COMPONENT_COMPILE_TIMEOUT_SECONDS” and set it to a new value. The set compile-time timeout value will apply to all components.

Be mindful that very long timeouts can cause stalled or stuck components if an issue arises. If a component is indefinitely compiling, increasing the timeout will not solve the root issue.