All Products
Search
Document Center

Function Compute:What do I do if a 502 error that contains the "Process exited unexpectedly before completing request" message is returned?

Last Updated:Feb 01, 2024

Causes

The HTTP server connection is actively closed due to the following possible causes:

  • The keep-alive mode is not configured for the connection.

  • The connection is closed after the HTTP server stays idle for a period of time.

  • The connection is closed when a read/write operation times out or an error occurs.

Solution

Function Compute uses the keep-alive mode to ensure that the HTTP server in a Custom Container runtime is connected. For idempotent requests such as the GET, HEAD, OPTIONS, and TRACE requests, the system retries to connect to the HTTP server when an error such as EOF or connection reset by peer occurs. However, for non-idempotent requests such as the POST and PATCH requests, 502 errors are returned when the connection fails. To prevent 502 errors, configure the following related parameters on the server on which the custom container runs:

  • Set the connection mode to keep-alive.

  • Disable the idle timeout feature of the HTTP server or set the idle timeout period to more than 15 minutes.

For different HTTP server frameworks, the configurations of the preceding parameters may be different. For example, for the GoFrame framework, you must configure the SetIdletimeout, ReadTimeout, and python uvicorn parameters. You must set SetIdletimeout to 0, and configure the --timeout-keep-alive parameter in the command line of python uvicorn. We recommend that you check whether the HTTP server is disconnected when sparse invocations are performed by an HTTP client in keep-alive mode.

Causes

The process unexpectedly exited because a function error occurred due to the following possible causes:

  • The exit operation is called.

  • The exception message that occurred during the function execution was not captured.

Solution

You can perform the following operations to resolve the issue:

  • Check whether an active exit logic is specified in your code.

  • Add exception capture or overwrite mechanisms at the top level of the process in the runtime environment to prevent processes from exiting when an exception occurs.