github web-platform-tests/wpt merge_pr_45956

latest releases: merge_pr_49470, epochs/three_hourly/2024-12-03_06H, epochs/six_hourly/2024-12-03_06H...
16 months ago

Fix error reporting in tools/serve/serve.py

In #45686 I reported the following log output:

❯ ./wpt serve
<irrelevant parts removed>
[2024-04-12 17:08:01,479 wss on port 33453] CRITICAL - Please ensure all the necessary WPT subdomains are mapped to a loopback device in /etc/hosts.
See https://web-platform-tests.org/running-tests/from-local-system.html#system-setup for instructions.

The underlying problem was actually GoogleChromeLabs/pywebsocket3#38 and had nothing to do with the content of /etc/hosts (which had already been set up).

The problem is that tools/serve/serve.py contains numerous points like the following:

try:
    # <do something>
except Exception:
    startup_failed(logger)

This swallows the actual exception, while startup_failed logs the message above. Since the actual problem is not as described, the logs are extremely misleading.

This change adds a log of the original exception to each location where the exception was swallowed. The log message includes enough context to help diagnose the problem.

With this change, the log output is as follows:

➜ ./wpt serve
<irrelevant parts removed>
[2024-04-29 18:01:15,751 wss on port 33175] CRITICAL - start_wss_server: Caught exception from WebSocketDomain: module 'ssl' has no attribute 'wrap_socket'
[2024-04-29 18:01:15,751 wss on port 33175] CRITICAL - Please ensure all the necessary WPT subdomains are mapped to a loopback device in /etc/hosts.
See https://web-platform-tests.org/running-tests/from-local-system.html#system-setup for instructions.

Don't miss a new wpt release

NewReleases is sending notifications on new releases.