Skip to content
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

Build timeout when trying to deploy Next.js #1427

Open
thomasgauvin opened this issue Mar 7, 2024 · 22 comments
Open

Build timeout when trying to deploy Next.js #1427

thomasgauvin opened this issue Mar 7, 2024 · 22 comments

Comments

@thomasgauvin
Copy link
Contributor

thomasgauvin commented Mar 7, 2024

I'm creating this issue to collect issues related to deploy timeouts/failed deploys for Next.js sites. I've seen a couple other threads get re-purposed into discussions for Next.js deployment issues, though they were originally intended for unrelated past deployment issues.

The asks are the following:

  1. Create a support issue, so that we can use that channel to collect more information and assess the severity of each issue.
  2. Deploy your Static Web Apps to West US 2 region. We have more thorough logging in that region uniquely and will be better enabled to assist.
  3. Share your default host name, and screenshot of failing deploys here.
  4. If standalone is enabled, turn it off and share if this has improved your deployment.

Looking forward to getting to the bottom of this, thanks everyone for the feedback!

@felicksLindgren
Copy link

felicksLindgren commented Mar 8, 2024

Hi, currently having deployment issues for both Free and Standard tier Static Web Apps. Both have Location "Global". I tried with removing 'standalone' without any luck. The host name your asking for, is that the URL to the app?

@krisnashaypp
Copy link

I'm having this issue today, Nextjs build runs fine in github actions but when "polling on deployment" it gives up after 600 seconds and shows "Deployment Failure Reason: Web app warm up timed out. Please try again later."

@thomasgauvin
Copy link
Contributor Author

@felicksLindgren, yes that's correct, the URL to the app. @krisnashaypp any chance you can also share your URL?

Please deploy your workloads to West US 2 (in the Advanced tab of the create blade) if you are able to, we have more thorough logs in that region.

Also, can you open support tickets so we can use that channel for more direct communication?

@felicksLindgren
Copy link

@thomasgauvin Where do you want to receive that support ticket? Here in GitHub as a seperate issue, or via Azure as a support request?

@krisnashaypp
Copy link

@thomasgauvin the URL is lively-grass-00c911a03.3.azurestaticapps.net

I didn't have permission in Azure to create support tickets but I've sent it up the chain.

@thomasgauvin
Copy link
Contributor Author

@felickLindgren, an Azure support request would be ideal so we can collect the information about your resource.

@krisnashaypp thanks for sharing, I'll relay this over to our team to look into it

@adziusmaster
Copy link

adziusmaster commented Mar 11, 2024

image

we are facing exactly the same issue for the whole day today, our host: https://ashy-desert-090506203.4.azurestaticapps.net/

@felicksLindgren
Copy link

felicksLindgren commented Mar 12, 2024

@felickLindgren, an Azure support request would be ideal so we can collect the information about your resource.

@krisnashaypp thanks for sharing, I'll relay this over to our team to look into it

@thomasgauvin Here's a Support Request number for one of our affected resources: 2403120050001398

@krisnashaypp
Copy link

@thomasgauvin
My support ticket 2403120050001076

Thanks!

@AaronCTech
Copy link

Just an update: this issue is still occurring with our build.

Awaiting approvals to cross-deploy to US West 2 and pending support issue creation.

@annikel
Copy link

annikel commented Mar 12, 2024

To determine if configured routing might be blocking specific health checks conducted during deployment, could you all please help us investigate the issue by creating a directory within your public folder named .test and include a health check file named health.html within it (public/.test/health.html)? Afterward, start up the application locally and verify if this file is reachable via the path /.test/health.html. If it's inaccessible, please investigate whether the routing rules in for example your middleware might be altering or blocking that path.

@AaronCTech
Copy link

AaronCTech commented Mar 12, 2024

@annikel

We do have zero-trust auth middleware that would absolutely block this.

Could you provide the specific files/folders that should remain visible, assuming it's not .test/health?

Edit: we did see Thomas's older comment in another issue regarding /public/.swa/health.html, and an early attempt at allowing access to that file did not solve the issue last week :\

@annikel
Copy link

annikel commented Mar 12, 2024

@AaronCTech In that case please make sure to allow health checks to /.swa/health.html

@AaronCTech
Copy link

The devil's in the details; this worked!

Note: .swa/health is not the same as .swa/health.html :)

TL;DR: allow .swa/health.html requests through your middleware.

@IgnacioAguirre
Copy link

IgnacioAguirre commented Mar 13, 2024

Hi @AaronCTech,
Would you mind to give more details regarding how did you remove authentication on route ".swa/health.html".
Were you using matchers as mentioned in https://next-auth.js.org/configuration/nextjs#middleware ?

@cerimorse
Copy link

cerimorse commented Mar 13, 2024

Hey @IgnacioAguirre, you can definitely make use of the Next.js matcher in middleware.js. You can use regex, so negative lookaheads would work well here. There's a few things we didn't want matched in our app so we just added the .swa path to our matcher config. If it's just .swa you want to exclude then you can do something like this:

export const config = {
  matcher: [
    /*
     * Match all request paths except for the ones starting with:
     * - .swa (Azure static web apps)
     */
    '/((?!.swa).*)',
  ],
}

Our builds started working again this morning after adding .swa to the matcher so hopefully this is useful!

ps thanks @annikel and @AaronCTech for the tips and solution!

@mateubo
Copy link

mateubo commented Mar 15, 2024

Hi @thomasgauvin,
Since last Thursday, we suddenly have been facing many issues with all ours Azure Static Web Apps (~20 instances), one of them being deployment timeouts.
Our support ticket TrackingID#2403080050002476 is mainly about the apps randomly being unavailable for seconds/minutes/even an hour, and engineers have been unable to resolve this so far.

But as for the deployment timeout. I tried disabling output: 'standalone', but this causes the Oryx build to fail:

Installing production dependencies in '/7ee63406-bafe-445c-8668-bf980c30bca5-swa-oryx/app/.oryx_prod_node_modules'...

Running 'yarn workspaces focus --all || yarn install --production'...

node:internal/modules/cjs/loader:1137
  throw err;
  ^

Error: Cannot find module '/7ee63406-bafe-445c-8668-bf980c30bca5-swa-oryx/app/.oryx_prod_node_modules/.yarn/releases/yarn-classic.cjs'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1134:15)
    at Module._load (node:internal/modules/cjs/loader:975:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.19.1
node:internal/modules/cjs/loader:1137
  throw err;
  ^

Error: Cannot find module '/7ee63406-bafe-445c-8668-bf980c30bca5-swa-oryx/app/.oryx_prod_node_modules/.yarn/releases/yarn-classic.cjs'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1134:15)
    at Module._load (node:internal/modules/cjs/loader:975:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.19.1


---End of Oryx build logs---
Oryx has failed to build the solution.

@mburumaxwell
Copy link

Picked the starter (https://github.com/staticwebdev/nextjs-hybrid-starter) and set it up with WestEurope which failed after 600 seconds. It did work with WestUS2 after 226 seconds.

@thomasgauvin is there any timeline or estimate on having this working in West Europe?

@RenMen
Copy link

RenMen commented Mar 19, 2024

Thanks annikel. The build time out error resolved after adding .swa matcher in middleware.

@mateubo
Copy link

mateubo commented Mar 19, 2024

@annikel we do not have any auth middleware, and /.swa/health.html is reachable. We have Static Web Apps deployed in West Europe, and we need to rerun the deployments (AzureStaticWebApp@0 DevOps task) multiple times until it finally comes through

@thomasgauvin
Copy link
Contributor Author

Thank you all for the feedback, opening support issues and sharing your default hostnames/site identifiers, we are going to be looking into this.

@aKroken
Copy link

aKroken commented Mar 20, 2024

Hi @thomasgauvin, Since last Thursday, we suddenly have been facing many issues with all ours Azure Static Web Apps (~20 instances), one of them being deployment timeouts. Our support ticket TrackingID#2403080050002476 is mainly about the apps randomly being unavailable for seconds/minutes/even an hour, and engineers have been unable to resolve this so far.

But as for the deployment timeout. I tried disabling output: 'standalone', but this causes the Oryx build to fail:

Installing production dependencies in '/7ee63406-bafe-445c-8668-bf980c30bca5-swa-oryx/app/.oryx_prod_node_modules'...

Running 'yarn workspaces focus --all || yarn install --production'...

node:internal/modules/cjs/loader:1137
  throw err;
  ^

Error: Cannot find module '/7ee63406-bafe-445c-8668-bf980c30bca5-swa-oryx/app/.oryx_prod_node_modules/.yarn/releases/yarn-classic.cjs'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1134:15)
    at Module._load (node:internal/modules/cjs/loader:975:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.19.1
node:internal/modules/cjs/loader:1137
  throw err;
  ^

Error: Cannot find module '/7ee63406-bafe-445c-8668-bf980c30bca5-swa-oryx/app/.oryx_prod_node_modules/.yarn/releases/yarn-classic.cjs'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1134:15)
    at Module._load (node:internal/modules/cjs/loader:975:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.19.1


---End of Oryx build logs---
Oryx has failed to build the solution.

Hello! We have experienced exactly the same scenario as you.
It started on Tuesday 12 March.
We find that static web apps go to sleep and take anywhere from seconds to minutes to work.
Also experience that our pipeline step AzureStaticWebApp@0 fails when the static web app is "sleeping". Otherwise it works.
Have you found anything out around this problem?
We are considering setting up an App service instead and see if it works better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests