Go Back

Force ipv4 in Bitbucket pipeline

Posted: 

This goes over my head but going to attempt to provide a little background.

I ran into this issue because I'm trying to wait for a web server to spin up in the pipeline so I can run some Cypress tests. Looks a little like this:

npm run start & npx wait-on -i 1000 -v http://localhost:3000/

IP confusion

Apparently the issue comes from a "happy eyeballs" issue. I wonder if I've written about this before...should have checked my own blog.

The tl;dr is that "happy eyeballs" will check both IPv4 and IPv6 and prefer one or the other if both exist. It's one of the those, "it just works" technologies. I guess node now defers to the operating system now for this feature.

https://en.wikipedia.org/wiki/Happy_Eyeballs

https://github.com/jeffbski/wait-on/issues/109

Script fix

I found this fix that seems to do the job in our pipelines. I haven't vetted everything in this script so buyer beware.

https://github.com/undergroundwires/privacy.sexy/blob/master/.github/actions/force-ipv4/force-ipv4.sh