Rabi Siddique
206 words
1 minutes
When E2E tests broke unexpectedly in CI

A while ago, our CI for end-to-end tests suddenly started failing, which was surprising since we had never encountered issues before. For example, in this workflow, the error message was:

Error: Timed out waiting for: http-get://localhost:5173

This was unexpected because everything worked fine locally. After investigating, I discovered that the issue was related to GitHub Actions runners.

This link provides good details on the cause of the issue. Due to reasons mentioned in the link, GitHub Actions runners were resolving localhost to the address to IPv6 address ::1. IPv6 address was given higher priority compared IPv4 address. You can catch the basics around localhost here and IP versions here.

Solutions that I came up with#

The first approach involved passing the --host flag to Vite when starting the development server in CI. This flag allows Vite to explicitly set the hostname for the server. You can read more about it over here.

vite --host

The second solution was to modify the Dockerfile to address DNS resolution Specifically, I set the NODE_OPTIONS environment variable to prioritize IPv4 DNS resolution over IPv6 by introducing the following line in the Dockerfile:

ENV NODE_OPTIONS=--dns-result-order=ipv4first

The other was one in my Dockerfile over here. I introduced this in Dockerfile:

NODE_OPTIONS=--dns-result-order=ipv4first

Further Reading#

When E2E tests broke unexpectedly in CI
https://rabisiddique.com/posts/ci-failure-ip-versions/
Author
Rabi Siddique
Published at
2024-08-17