Skip to content

Commit

Permalink
[wptrunner] Report crash when WebDriver browser is not alive (#45833)
Browse files Browse the repository at this point in the history
This aligns with how the base class `TimedRunner` differentiates
`CRASH` from other failure modes [0].

An `InvalidSessionIdException` after a browser death (e.g., [1]) is now
coerced to `CRASH`, not the generic `INTERNAL-ERROR` for harness
exceptions.

Fixes #39617 and https://crbug.com/41485463.

[0]: https://github.com/web-platform-tests/wpt/blob/c338ceff/tools/wptrunner/wptrunner/executors/base.py#L216-L231
[1]: https://github.com/web-platform-tests/wpt/blob/c338ceff/tools/wptrunner/wptrunner/executors/base.py#L773
  • Loading branch information
jonathan-j-lee authored Apr 22, 2024
1 parent 4c6ce3e commit a883c77
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tools/wptrunner/wptrunner/executors/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def run_test(self, test):
result = self.do_test(test)
except Exception as e:
exception_string = traceback.format_exc()
message = f"Exception in TextExecutor.run:\n{exception_string}"
message = f"Exception in TestExecutor.run:\n{exception_string}"
self.logger.warning(message)
result = self.result_from_exception(test, e, exception_string)

Expand Down
7 changes: 5 additions & 2 deletions tools/wptrunner/wptrunner/executors/executorwebdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,9 @@ def run_func(self):
self.result = True, self.func(self.protocol, self.url, self.timeout)
except (error.TimeoutException, error.ScriptTimeoutException):
self.result = False, ("EXTERNAL-TIMEOUT", None)
except (socket.timeout, error.UnknownErrorException):
except socket.timeout:
# Checking if the browser is alive below is likely to hang, so mark
# this case as a CRASH unconditionally.
self.result = False, ("CRASH", None)
except Exception as e:
if (isinstance(e, error.WebDriverException) and
Expand All @@ -548,11 +550,12 @@ def run_func(self):
# workaround for https://bugs.chromium.org/p/chromedriver/issues/detail?id=2001
self.result = False, ("EXTERNAL-TIMEOUT", None)
else:
status = "INTERNAL-ERROR" if self.protocol.is_alive() else "CRASH"
message = str(getattr(e, "message", ""))
if message:
message += "\n"
message += traceback.format_exc()
self.result = False, ("INTERNAL-ERROR", message)
self.result = False, (status, message)
finally:
self.result_flag.set()

Expand Down

0 comments on commit a883c77

Please sign in to comment.