diff --git a/python/sglang/test/test_utils.py b/python/sglang/test/test_utils.py index ed95ccd7081d..1ce73715d884 100644 --- a/python/sglang/test/test_utils.py +++ b/python/sglang/test/test_utils.py @@ -447,6 +447,16 @@ def popen_launch_server( start_time = time.time() with requests.Session() as session: while time.time() - start_time < timeout: + + # check if server process has crashe/exited + return_code = process.poll() + if return_code is not None: + # Server failed to start (non-zero exit code) or crashed + raise Exception( + f"Server process exited with code {return_code}. " + "Check server logs for errors." + ) + try: headers = { "Content-Type": "application/json; charset=utf-8",