Description:
Problem
During long-running template builds, wait_for_build_finish polls the build status endpoint repeatedly. If the HTTP/2 connection is dropped by the server (e.g., due to idle timeout or server-side connection recycling), the polling loop throws an unhandled ConnectionTerminated exception and the entire build wait fails — even though the build itself is still running fine on the server.
Note: The "Build finished" log is misleading — it comes from the finally block in Template.build(), not from the build actually completing. The real cause is a connection drop during status polling.
Root Cause
In both template_async/build_api.py and template_sync/build_api.py, wait_for_build_finish calls get_build_status without any error handling for transient network/connection errors. Any non-BuildException exception (like h2.exceptions.ConnectionTerminated, httpx.RemoteProtocolError, httpcore.ConnectionNotAvailable, etc.) immediately kills the polling loop.
Expected Behavior
Transient connection errors during status polling should be retried automatically, since the build is still running server-side. The function should only fail if:
The API explicitly returns an error status (BuildException)
Connection errors persist beyond a reasonable retry limit
Environment
e2b SDK version: 2.27.0
Python: 3.12
HTTP client: httpx with h2 (HTTP/2)
Description:
Problem
During long-running template builds, wait_for_build_finish polls the build status endpoint repeatedly. If the HTTP/2 connection is dropped by the server (e.g., due to idle timeout or server-side connection recycling), the polling loop throws an unhandled ConnectionTerminated exception and the entire build wait fails — even though the build itself is still running fine on the server.
Note: The "Build finished" log is misleading — it comes from the finally block in Template.build(), not from the build actually completing. The real cause is a connection drop during status polling.
Root Cause
In both template_async/build_api.py and template_sync/build_api.py, wait_for_build_finish calls get_build_status without any error handling for transient network/connection errors. Any non-BuildException exception (like h2.exceptions.ConnectionTerminated, httpx.RemoteProtocolError, httpcore.ConnectionNotAvailable, etc.) immediately kills the polling loop.
Expected Behavior
Transient connection errors during status polling should be retried automatically, since the build is still running server-side. The function should only fail if:
The API explicitly returns an error status (BuildException)
Connection errors persist beyond a reasonable retry limit
Environment
e2b SDK version: 2.27.0
Python: 3.12
HTTP client: httpx with h2 (HTTP/2)