SWA broken as of node version `20.13.0`
cr3wdayt5p opened this issue · 8 comments
Describe the bug
The SWA CLI does not work with node version 20.13.0
or later (also tested with 20.13.1
and 22.1.0
).
There are no issues with node 20.12.2
.
Running swa start
does not report any errors. However after succesful startup of swa start
the URL https://127.0.0.1:8082
(or https://localhost:8082
) simply refuse connections (Chrome report ERR_CONNECTION_REFUSED
).
To Reproduce
Steps to reproduce the behavior:
- With node
20.12.2
setup some SWA project. Verify thatswa start
work as expected. - Upgrade to node
20.13.0
. SWA is no longer working (butswa start
report no errors).
Expected behavior
Nothing should break upgrading from node 20.12.2
to 20.13.0
(or later).
Desktop (please complete the following information):
- OS: macOS 14.4 (arm64)
- SWA CLI version:
1.1.7
Additional context
swa-cli.config.json
:
{
"configurations": {
"app": {
"appDevserverUrl": "https://127.0.0.1:8081",
"host": "127.0.0.1",
"port": 8082,
"ssl": true,
"sslCert": "localhost-cert/localhost.crt",
"sslKey": "localhost-cert/localhost.key"
}
}
}
can reproduce.
seems that it's binding to the external ip of the local machine.
Also reproduced.
swa --version =
1.1.8
sw_vers =
ProductName: macOS
ProductVersion: 14.5
BuildVersion: 23F79
I investigated and it seems that there has been a change in the behavior of node's http module.
ref: nodejs/node#53204
There are two ways to deal with this.
The first is to access it with a localIpAdress address. (e.g. 192.168.xxx.xxx)
The second is to remove the following line (I would like to ask for instructions from the product owner 👀)
static-web-apps-cli/src/msha/server.ts
Line 174 in 352be8f
If you do either of these, it looks like you can get it to work with
@yamachu can you expand on what you mean by:
The first is to access it with a localIpAdress address. (e.g. 192.168.xxx.xxx)
please?
Normally when you are developing an application using the SWA CLI, you would access the web front application by accessing http://127.0.0.1:8082 or http://localhost:8082
Instead, you access it by typing the localIp address(private ip address?) in the address bar of your browser within the network to which the machine you are currently serving is part of (you can see this address in ifconfig, etc.).
Ah I see - so this would not be something that you could commit to source control as it would be potentially different for each user.
Incidentally I can reproduce this with 1.1.9 also.
Highly recommend using patch-package (https://www.npmjs.com/package/patch-package) on this project at this point.
Lets you do little tweaks like the above PR and check it into source control so any developer on the team can benefit.
We've released version 1.1.10 recently that explicitly has Node 20 support. Please let us know if you are still having problems.
Thanks!