static-web-apps-cli: Dependency on json.schemastore.org breaks CLI
The SWA CLI currently fails and stops after a few seconds, because either the latency of https://json.schemastore.org/staticwebapp.config.json is too high or the service is not available. There should be no dependency on an online resource to be available for local development. From the logs it seems like it should continue to work without validation, but it currently doesn’t.
Logs:
[swa] network timeout at: https://json.schemastore.org/staticwebapp.config.json
[swa] ✖ Failed to load staticwebapp.config.json schema. Continuing without validation!
[swa] node "C:\Users\USER\AppData\Local\pnpm\global\5\.pnpm\@azure+static-web-apps-cli@1.1.6\node_modules\@azure\static-web-apps-cli\dist\msha\server.js" exited with code 0
--> Sending SIGTERM to other processes..
[dataApi] cd "C:\repos\APP\data-api" && "C:\Users\USER\.swa\dataApiBuilder\0.9.7\Microsoft.DataApiBuilder.exe" start -c staticwebapp.database.config.json --no-https-redirect exited with code 1
--> Sending SIGTERM to other processes..
[run] cd "C:\repos\APP\app" && pnpm dev exited with code 1
✖ SWA emulator stopped because the --run command exited with code 1.
My suggestion would be to increase the timeout for the request and to fix the bug that stops the CLI from working without validation.
About this issue
- Original URL
- State: closed
- Created 4 months ago
- Reactions: 25
- Comments: 21 (2 by maintainers)
Commits related to this issue
- Create staticwebapp.config.schema.json Temporary solution while waiting on a fix for: https://github.com/Azure/static-web-apps-cli/issues/802 — committed to MohamedMrj/b3-event-management by sebdanielsson 4 months ago
Thanks for all of your feedback. We are going to have a local backup schema as a fallback option if the download fails. I have reopened the issue #754, and the fix will come soon.
Hi @jancimajek, in v1.1.4 SWA-CLI skipped validation and continued deploying if timeout. However, it will make routing to not work. So I recommend not to skip validation, but use the 1.1.7-alpha version with my fix instead: https://github.com/Azure/static-web-apps-cli/issues/754#issuecomment-1977411452. The official release will come soon.
Another workaround is to use version 1.1.4.
What is the current status for resolving this issue @cjk7989 ?
Same problem here:
Also having this problem, since the 1st of March:
Heavy plus one! We use this CLI deploy our production sites, so this is really blocking us from release
It is this line that makes this fail. It should not send
true
as the second argument astrue
is used to signallogger.error
to exit the program.https://github.com/Azure/static-web-apps-cli/blob/f9f9b7e92f5fb03cf9b75626377f951a5f85cd5d/src/core/utils/user-config.ts#L108
Anyone using Github Actions could use https://github.com/Azure/static-web-apps-deploy directly instead of the SWA CLI (as mentioned in #754).
Don’t know if this helps anyone, but I did the following this morning to unblock all of our deployment pipelines.
false
, as the second argument tologger.error
https://github.com/Azure/static-web-apps-cli/blob/f9f9b7e92f5fb03cf9b75626377f951a5f85cd5d/src/core/utils/user-config.ts#L108name
inpackage.json
to@myprivateorg/static-web-apps-cli-hotfix
npm run build
npm pack
npm publish
npx @myprivateorg/static-web-apps-cli-hotfix ...
instead ofnpx @azure/static-web-apps-cli
This worked for us, but some maintainer said here that this might not work 🤷 I guess do this at your own risk or whatever.