-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[start] Start command does not connect to web or api server on Node 18 #663
Comments
Hi @sinedied , is there any alternative that we can use instead of "wait-on" package? |
As a temporary workaround you can use 127.0.0.1 in stead of localhost for the API and/or for the frontend, use it like this:
Mind that the port number 3010 can be different on your side of course, and you should add your own extra parameters. |
None that I know of. This is problematic in the whole Node.js ecosystem as they made the changed the priority order from ipv4 to ipv6.
You're right, but the One issue is that once the |
You are right, but that's why you include the --host in combination with the --api-location option (and not the --api-devserver-url option), in my example I omitted the api-location option, but it should look something like: swa start --host=127.0.0.1 --app-devserver-url=http://127.0.0.1:<DEVSERVER-PORT> --run "<RUN COMMAND>" --api-location ./api --port <SWA-PORT> --api-port <API-PORT> |
This is so painful from user perspective, may be we should try giving these params internally while starting the swa if the node version is 18. |
Agreed that it's painful from a user perspective, but the problem is in the related package wait-on which resolves to the ::1 IPv6 address. I don't think it's a SWA-CLI specific issue. |
We can't do that, as some servers listen on ipv6 by default and works fine with http://localhost, but would break with http://127.0.0.1 (Node.js server running on Node 18 for example). |
Another workaround to get people going with node 18. Using swa 1.1.1 and Node 18.12.1 i was able to get everything to work as expected with
My react apps runs on 3000 (Vite React) |
I was getting this issue on Win 11. I switched to running the swa start in WSL and it is working for me again with node 18. |
Thought I'd share my own workaround. I installed concurrently:
Then I separated out my front end / back end scripts like so: "debug": "concurrently -n \"staticwebapp,functionapp\" -c \"bgBlue.bold,bgMagenta.bold\" \"npm run debug:staticwebapp\" \"npm run debug:functionapp\"",
"debug:staticwebapp": "cd src/StaticWebApp && npm run debug",
"debug:functionapp": "cd src/FunctionApp && func start", Where the "debug": "swa start http://localhost:5173 --run \"npm run dev\" --api-location http://127.0.0.1:7071", This allows me to work around the issue. https://johnnyreilly.com/static-web-apps-cli-node-18-could-not-connect-to-api |
Can Node.js server successfully listen on localhost (resolved to ipv6)? In fact, I find "server.listen()" can not listen on ipv6 hosts like [::1]:4280, while listen on 127.0.0.1 works well. |
the work around the worked for me was with my Angular application
|
We release swa-cli v1.1.3 and the issue has been fixed in PR #704. If you encounter any problems, please feel free to continue the discussion here. |
I'm still getting the error with version 1.1.3. I'm using nvm for Windows and node 18.16.1. |
Is there any detailed error message? You can run swa start with augment "--verbose=silly" to see it. |
My logs: ➜ swa start --verbose=silly Welcome to Azure Static Web Apps CLI (1.1.3) Getting config file options from swa-cli.config.json...
Checking if localhost:4280 is accepting TCP connections...
➜ swa start --host=127.0.0.1 Welcome to Azure Static Web Apps CLI (1.1.3) Using configuration "my-app-angular" from file:
[api] MSBuild version 17.7.0-preview-23273-06+7d65cb31c for .NET ➜ swa start --host=127.0.0.1 --verbose=silly Welcome to Azure Static Web Apps CLI (1.1.3) Getting config file options from swa-cli.config.json...
Checking if 127.0.0.1:4280 is accepting TCP connections...
|
I also still have this issue with Node 18. When I start my dev server manually before executing |
Hi @jorgelevy and @jochenjonc, thanks for your feedback. We solved this issue in #720, now dev servers can be reached, and there is no need to set --host=127.0.0.1. Before a new version of swa-cli is released, you can feel free to download and test it from GitHub. Here are the steps:
Happy to know if it is ok or still have any problems. |
@cjk7989 I've tested it and it is fixed. 👍 Can't wait for the release. |
Please could the fix be released? |
Working for me as well, thank you! |
We are happy to inform you that a new release has been published that fixed the issue. Please update swa-cli to v1.1.4 and let us know if you encounter any issues. Thanks for your feedback and support. |
With the latest version (v1.1.4) I get a lot of log spam:
The site works as expected though, nothing is broken, but I have no idea why 127.0.0.1 is there. I use localhost in the startup command:
|
Working for me. Thanks!! Needed to update my npm and uninstall all my packages (angular, swa cli, and azure functions cli), and install new packages versions. |
It works for me as well, the main problem is that the performance of the site is terrible when compared not running through swa cli. Pages take long time to load and resources (for example > 1s to load a font) |
It's getting quite tedious waiting for a fix, tbh. |
When will this be fixed? I keep getting the below in
workaround of using This worked fine in |
Hi @ArmaanMcleod, the connection issue should have been fixed from 1.1.4. I guess it may due to your network failure of 127.0.0.1. But I can help you find the reason. Could you provide the framework type of your app, swa-cli.config.json (if you have) and your command to run swa-cli? |
Hi @cjk7989. Thanks for your response. Looks like the issue fixed itself when I upgraded my |
As I'm encountering this issue using Node 16.16.0 could I confirm which version of Node you're now using? TIA! |
I have a Blazor WASM project with a database connection to a local CosmosDB emulator. Upon
Could anyone give any guidance on what might be the problem? I've tried swapping out Node 18-16 and back, and am using SWA CLI 1.1.4. TIA! |
Hi @jacksorjacksor, both node 16 and 18 are supported in [email protected]. Firstly I suggest to check whether your Blazor WASM project starts the dev server localhost:8000 successfully before swa-cli try to connect to it. You can just run the start up command and check if the app runs on localhost:8000. The start up command for you seems to be: |
Hi @cjk7989 thanks for this - yes this runs the Blazor app but on port 5296 - I'll look to change that to 8000 and get back to you |
YES that was it! Huge apologies, thank you!! Oh that's really obvious in retrospect. Ports changed from 5296 -> 8000 in launchSettings.json. ...the next issue being that |
That's ok. Or you can add a parameter of swa-cli: "--appDevserverUrl http://localhost:5296" or add this to swa-cli.config.json generated by "swa init". |
It's suggested here: jeffbski/wait-on#137 (comment) That the issue may not arise with Node.js 20. possibly worth testing if upgrading to 20 removes the issue |
Thanks to @bzbetty for suggesting, there is a way to improve performance (or perhaps work around the SWA CLI perf regression since 1.1.4). I've written it up here: https://johnnyreilly.com/static-web-apps-cli-improve-performance-with-vite-server-proxy |
Before filing this issue, please ensure you're using the latest CLI by running
swa --version
and comparing to the latest version on npm.Are you accessing the CLI from the default port
:4280
?--port
) and accessing the CLI from that port:4280
ℹ️ NOTE: Make sure to enable debug logs when running any
swa
commands using--verbose=silly
Describe the bug
On Node 18,
npm start
never connects to a web or api server, it's stuck until timeout. On Node 16, no issue.This is related to this issue jeffbski/wait-on#137 of the
wait-on
package.The text was updated successfully, but these errors were encountered: