Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
318 stars 53 forks source link

Deployment Failure Reason: Web app warm up timed out #1496

Open dharmendrasha opened 2 weeks ago

dharmendrasha commented 2 weeks ago

Describe the bug

I have a static nextjs app that used to work for 6-7 weeks ago but have stopped working even for the smallest change. I even reverted the branch to the exact commit that was successfully built last time and it still fails with "Deployment Failure Reason: Web app warm up timed out. Please try again later." after having being stuck in "Status: InProgress." for 10 minutes.

To Reproduce Steps to reproduce the behavior:

Trigger build by restarting the following Github Actions job: https://github.com/dexie/dexie-cloud/actions/runs/8377209871/job/22938762204 (I can provide access to whom may look into this) See error "Deployment Failure Reason: Web app warm up timed out. Please try again later." after having being stuck in "Status: InProgress." for 10 minutes. Compare it with the last successful job https://github.com/dexie/dexie-cloud/actions/runs/7733486859/job/21085673246 that is based on the exact same commit. Github workflow file (.github/workflows/azure-static-web-apps-proud-meadow-0514cdf10.yml):

I am facing the same issue as here #1440

re opening it because I am facing this a lot for my app

name: Azure Static Web Apps CI/CD

on:
  push:
    branches:
      - dxcman
  pull_request:
    types: [opened, synchronize, reopened, closed]
    branches:
      - dxcman

jobs:
  build_and_deploy_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
    runs-on: ubuntu-latest
    name: Build and Deploy Job
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: true
      - name: Build And Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_PROUD_MEADOW_0514CDF10 }}
          repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
          action: "upload"
          ###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
          # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
          app_location: "/libs/dexie-cloud-manager/" # App source code path
          api_location: "" # Api source code path - optional
          output_location: "" # Built app content directory - optional
          app_build_command: "yarn build"
          api_build_command: "rm -rf ./node_modules/@next/swc-* && rm -rf ./.next/cache"
          ###### End of Repository/Build Configurations ######

  close_pull_request_job:
    if: github.event_name == 'pull_request' && github.event.action == 'closed'
    runs-on: ubuntu-latest
    name: Close Pull Request Job
    steps:
      - name: Close Pull Request
        id: closepullrequest
        uses: Azure/static-web-apps-deploy@v1
        with:
          app_location: "/libs/dexie-cloud-manager/" # App source code path
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_PROUD_MEADOW_0514CDF10 }}
          action: "close"

image

joechoi-git commented 2 weeks ago

I had the same issue, but once I updated the Next build to build the app with the standalone mode, the deployment started working for me.

Here are the steps that you can do.

next.config.js

const nextConfig = {
    output: "standalone"
};

package.json

    "scripts": {
        "build": "next build && cp -r .next/static .next/standalone/.next/ && cp -r public .next/standalone/"
    }

azure-pipeline.yml

                app_location: "/" # App source code path
                api_location: "" # Api source code path - optional
                output_location: "" # Built app content directory - optional
                app_build_command: "npm run build"
                api_build_command: "rm -rf ./node_modules/@next/swc-* && rm -rf ./.next/cache"
dharmendrasha commented 1 week ago

First of all thanks man for this great tip this worked like a charm

Zaneris commented 4 days ago

Never had an issue before this week, today it decided to start timing out on every attempt, but your fix resolved it @joechoi-git

image