Azure / static-web-apps-cli

Azure Static Web Apps CLI ✨
https://aka.ms/swa/cli-local-development
MIT License
599 stars 118 forks source link

Deployment Failure Reason: spawn EBUSY #721

Open tobiasdiez opened 1 year ago

tobiasdiez commented 1 year ago

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 ?

Make sure you are accessing the URL printed in the console when running swa start!

ℹ️ NOTE: Make sure to enable debug logs when running any swa commands using --verbose=silly

Describe the bug Sometimes the deployment via swa deploy fails on CI.

##[debug]Evaluating: secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_MANGO_PEBBLE_0224C3803
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'AZURE_STATIC_WEB_APPS_API_TOKEN_MANGO_PEBBLE_0224C3803'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Evaluating condition for step: 'Deploy Web App'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Deploy Web App
##[debug]Loading inputs
##[debug]Evaluating: format('# Delete old deployment (otherwise we get a spawn EBUSY error when running the workflow again)
##[debug]az staticwebapp environment delete --name jabref-online --environment-name {0} --yes || true
##[debug]
##[debug]yarn swa deploy .output\public --env {1}
##[debug]', matrix.deployment_environment, matrix.deployment_environment)
##[debug]Evaluating format:
##[debug]..Evaluating String:
##[debug]..=> '# Delete old deployment (otherwise we get a spawn EBUSY error when running the workflow again)
##[debug]az staticwebapp environment delete --name jabref-online --environment-name {0} --yes || true
##[debug]
##[debug]yarn swa deploy .output\public --env {1}
##[debug]'
##[debug]..Evaluating Index:
##[debug]....Evaluating matrix:
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'deployment_environment'
##[debug]..=> 'default'
##[debug]..Evaluating Index:
##[debug]....Evaluating matrix:
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'deployment_environment'
##[debug]..=> 'default'
##[debug]=> '# Delete old deployment (otherwise we get a spawn EBUSY error when running the workflow again)
##[debug]az staticwebapp environment delete --name jabref-online --environment-name default --yes || true
##[debug]
##[debug]yarn swa deploy .output\public --env default
##[debug]'
##[debug]Result: '# Delete old deployment (otherwise we get a spawn EBUSY error when running the workflow again)
##[debug]az staticwebapp environment delete --name jabref-online --environment-name default --yes || true
##[debug]
##[debug]yarn swa deploy .output\public --env default
##[debug]'
##[debug]Loading env
Run # Delete old deployment (otherwise we get a spawn EBUSY error when running the workflow again)
##[debug]C:\Program Files\PowerShell\7\pwsh.EXE -command ". 'D:\a\_temp\962b834b-afe0-484e-8e84-9c35b7e02f5a.ps1'"
ERROR: Operation returned an invalid status 'Bad Request'

Welcome to Azure Static Web Apps CLI (1.1.2)

Deploying front-end files from folder:
  D:\a\JabRefOnline\JabRefOnline\.output\public

Consider providing api-language and version using --api-language and --api-version flags,
    otherwise default values apiLanguage: node and apiVersion: 16 will apply

Deploying to environment: default

Found configuration file:
  D:\a\JabRefOnline\JabRefOnline\staticwebapp.config.json

Deploying project to Azure Static Web Apps...
Could not find StaticSitesClient local binary
- Downloading https://swalocaldeploy.azureedge.net/downloads/1.0.023421/windows/StaticSitesClient.exe@1.0.023421
[swa] ✔ Downloading https://swalocaldeploy.azureedge.net/downloads/1.0.023421/windows/StaticSitesClient.exe@1.0.023421
- Preparing deployment. Please wait...

✖ 
✖ Deployment Failed :(
✖ Deployment Failure Reason: spawn EBUSY
✖ For further information, please visit the Azure Static Web Apps documentation at https://docs.microsoft.com/azure/static-web-apps/
✖ If you believe this behavior is unexpected, please raise a GitHub issue at:
  https://github.com/Azure/static-web-apps-cli/issues/new/choose
Error: Process completed with exit code 1.
##[debug]Finishing: Deploy Web App

e.g. https://github.com/JabRef/JabRefOnline/actions/runs/5480147768/jobs/9989069413

To Reproduce Steps to reproduce the behavior:

  1. Run swa deploy in CI.

Expected behavior Deployment is successful.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

cjk7989 commented 1 year ago

+1. We also noticed this problem, and re-run the job can help. We will investigate it.

chris-kruining commented 1 year ago

+1. also run into this issue pretty often. the only clue I have found, is that for some reason the error seems less prevalent when I tell everyone to close the app. Given that our swa runs on a windows license makes me suspect that it could be windows file locking. But I would like to say this is mostly just a guess

quality-leftovers commented 1 year ago

+1. Observed this issue in our deployment pipeline today (azure devops)

quality-leftovers commented 1 year ago

Still happens a lot. Any update?

quality-leftovers commented 1 year ago

So anyone got a solution / workaround aside from CallAzureThingyInLoopBecauseOfRandomFailures()?

chris-kruining commented 1 year ago

no solution yet

TonyLunt commented 1 year ago

FWIW, we are seeing this issue more often than not when attempting to deploy.

If it helps, we are using a "swa deploy" AZ CLI command on a windows-latest Microsoft-hosted agent. The agents appear to be running AZ CLI version 2.52.0 and SWA CLI version 1.1.4.

alexhowgego commented 11 months ago

Same here - seeing this periodically on Windows Azure build agent

chris-kruining commented 11 months ago

for us switching to linux agents seems to have "fixed" the issue. When you dig down into the EBUSY error you get some answers that I think hinted towards file locking. That combined with the linux agent not (yet) haiving this issue seems to confirm that for me

fede commented 4 months ago

A year since this... still with the same issue... unbelievable

ArnavWee commented 4 months ago

This has become a daily occurrence at this point, any updates on when this will be fixed or is it even going to be fixed

adrianhall commented 4 months ago

I have not been able to reproduce. Are you running two deployments simultaneously? What does your pipeline actually look like?

tobiasdiez commented 4 months ago

@adrianhall thanks for investigating this.

We run swa deploy for each PR / push to main (https://github.com/JabRef/JabRefOnline/blob/74f66358c02700d26ce94a0211d2f561227233c5/.github/workflows/deploy-preview.yml#L65-L68). Sometimes this indeed results in deployments that happen roughly at the same time, but most often this is not the case.

Since this issue happens only sometimes and I couldn't yet discover a pattern behind it.

Do you know if that error would be triggered on the user's side or on the server? In the later, could you access the server logs if I give you our azure data? In that case, please feel free to write me an email.

fede commented 4 months ago

@adrianhall thanks for investigating this.

We run swa deploy for each PR / push to main (https://github.com/JabRef/JabRefOnline/blob/74f66358c02700d26ce94a0211d2f561227233c5/.github/workflows/deploy-preview.yml#L65-L68). Sometimes this indeed results in deployments that happen roughly at the same time, but most often this is not the case.

Since this issue happens only sometimes and I couldn't yet discover a pattern behind it.

Do you know if that error would be triggered on the user's side or on the server? In the later, could you access the server logs if I give you our azure data? In that case, please feel free to write me an email.

Similar experience. Now it has been working without issues for over a week. But when it starts to fail it fails for 24/48hs straight... with some deployments passing.

ArnavWee commented 4 months ago

I have not been able to reproduce. Are you running two deployments simultaneously? What does your pipeline actually look like?

For us, we don't have any concurrent deployments running , we manuly trigger github actions and only have one deployment running at a time to SWA

adrianhall commented 4 months ago

I understand the environment now. I'm investigating.

MatteoSp commented 2 months ago

Same here, about 50% failures . Running version 2.0.1 from a self-hosted Azure DevOps build agent.

esciullo commented 1 month ago

Issue is still present also for me