quasar-testing icon indicating copy to clipboard operation
quasar-testing copied to clipboard

Quasar, Vite, Cypress out-the-box config hanging on Node 18

Open KrisCarr opened this issue 3 years ago • 3 comments

Software version

OS: Macos / Windows 10 Node: 18.2.0 NPM: 8.10.0 Any other software related to your bug:

What did you get as the error?

running the generated script test:e2e or test:e2e:ci causes a hang. Upon adding the debug environment variable for start-test it is getting a connection refused on ::1

What were you expecting?

Cypress to start

What steps did you take, to get the error?

  • Install quasar via yarn create quasar choosing vite.
  • Add the quasar testing extension choosing cypress.
  • run yarn test:e2e or yarn test:e2e:ci

Current fix / workaround

It appears the generated scripts in package.json tell start-test to listen for http-get://localhost:9000 which is resolving to ::1 at runtime. This is not listened on by quasar dev out-the-box.

The current fix is to change the script to listen for http-get://127.0.0.1:9000 to force ipv4 or to change the listen address for the dev server.

KrisCarr avatar May 31 '22 15:05 KrisCarr

Seems like a problem with Node 18, as I cannot reproduce it on Node 14 or 16 That said, half the packages around won't support Node 18 yet, so we don't see this a priority for now Please use Node 14 or 16 for now

Thanks for reporting anyway, we'll work on this later on

IlCallo avatar Jun 01 '22 09:06 IlCallo

Having the same issue here and can confirm that switching back to Node 16 helped.

However I decided to follow the workaround proposed by @KrisCarr and used http-get://127.0.0.1:9000 with Node 18 and it worked.

Thanks @KrisCarr !

mv-go avatar Jun 01 '22 10:06 mv-go

I'm pretty sure there was a reason why I didn't go with 127.0.0.1 in the first place, but I'm not sure which was it I think browsers or os have some special handling for localhost keyword which bypass some security checks I'll explore that option again in the future

IlCallo avatar Jun 01 '22 11:06 IlCallo

@KrisCarr, @IlCallo, @mv-go, I have faced the same issue in my project/setup, but I've also found a different workaround: put the http:// before the localhost. To be more clear: replace http-get://localhost:9000 with http-get://http://localhost:9000. In my case it solves the problem, and I'd be more than happy to hear from you! 🙂

staszek998 avatar Feb 20 '23 12:02 staszek998

I just tried it out again today and could not reproduce with this setup

Ubuntu: 22.04 Node: 18.14.1 NPM: 9.3.1 Cypress: 12.7.0

Is this an issue only on Windows/Mac?

IlCallo avatar Feb 28 '23 13:02 IlCallo

Is this an issue only on Windows/Mac?

@IlCallo, it might be, but it should probably be confirmed by somebody else (more testers needed).

staszek998 avatar Feb 28 '23 14:02 staszek998

@IlCallo I have re-tested and can confirm it is still an issue at least on macOS with M1 chip (don't have access to another machine at the moment to test others).

I first tried with Node 18.12.0 that was currently installed then updated to 18.14.2

Updated reproduction commands:

yarn create quasar choosing options: Vite, Typescript

yarn quasar ext add @quasar/testing-e2e-cypress choosing options: Scripts & Typescript (didn't bother ticking coverage)

This then hangs silently in a retry loop failing to connect to ::1, it does eventually give up after quite a while: yarn test:e2e:ci

Running this shows the verbose output showing the underlying attempts: DEBUG=start-server-and-test yarn test:e2e:ci

Output:

making HTTP(S) get request to  url:http://localhost:9000 ...
  HTTP(S) error for http://localhost:9000 Error: connect ECONNREFUSED ::1:9000
making HTTP(S) get request to  url:http://localhost:9000 ...
  HTTP(S) error for http://localhost:9000 Error: connect ECONNREFUSED ::1:9000
making HTTP(S) get request to  url:http://localhost:9000 ...
  HTTP(S) error for http://localhost:9000 Error: connect ECONNREFUSED ::1:9000

Full output from command execution to the above (attached to save space):

output.txt

KrisCarr avatar Mar 02 '23 17:03 KrisCarr

I have the exact same problem with:

  • M1 macOS (Ventura 13.3.1)
  • Node.js 18.16.0
  • Cypress 12.13.0.

In my case the error reported is:

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

Reverting to Node.js 16 solves this.

maiolica avatar May 30 '23 02:05 maiolica

Hey there, did anyone test this on latest versions of Node 18 or even Node 20? I still don't own a Mac, and don't plan to buy one soon, but since the problem is obviously related to Node 18 I guess the best course of action would be to search for similar issues into Node repo

IlCallo avatar Sep 13 '23 17:09 IlCallo

A guy on Discord tested with Node 20 on Windows and apparently it works on that version I still have no idea why only Node 18 is failing and why only on Windows or Mac, but since Node 20 is already out since some time, skipping Node 18 altogether could be a workaround to the problem without being stuck on Node 16 which is close to EOL

IlCallo avatar Sep 14 '23 14:09 IlCallo

I'm on a Mac (13.5.2) using Node 20 and Cypress 13, the fix for me was replacing localhost with 127.0.0.1 in both cypress.config.ts and package.json scripts, after doing this everything is working fine for me.

maiolica avatar Sep 15 '23 04:09 maiolica

This seems to be the culprit: https://github.com/nodejs/node/issues/47785

Node <18 resolved localhost to 127.0.0.1, while Node >= 18 (on Mac for sure, and on Windows for Node 18 for sure) resolve to its IPv6 counterpart ::1

IlCallo avatar Sep 18 '23 12:09 IlCallo

As expected, took me quite a while to properly understand issue root and test the fix I just tagged Cypress AE v5.2 with the fix, which will of course only apply to newly generated projects

If you're curious about the backstory, check these links out: https://github.com/quasarframework/quasar-testing/commit/8552ba37abf309d8e230eb150b596ae5b2d28cbb#diff-0df604707cf8f7ef7a25247848b4f8ef0383458d0138fb6e50af9f8d17554079R84-R95

TL;DR: Node 18 did a mess with localhost resolution mechanism, thus the need to use 127.0.0.1, Node 20 implemented "Happy Eyeballs" protocol which should make everything work as it was before We'll revert to using localhost when Node 18 won't be maintained anymore

IlCallo avatar Dec 27 '23 17:12 IlCallo

Well done, @IlCallo! Thank you! ❤️

staszek998 avatar Dec 28 '23 04:12 staszek998

Thank you for your patience 😁

IlCallo avatar Dec 28 '23 10:12 IlCallo