firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

next.config.js bundle timeout deploys a broken build

Open rasendubi opened this issue 2 years ago • 6 comments

https://github.com/firebase/firebase-tools/pull/5691 introduced a 10s timeout for bundling next.config.js. This bundling uses npx esbuild next.config.js command and it may timeout for a variety of reasons (most likely, network-related).

When this happens, the code fallbacks to copying next.config.js to the output. However, if next.config.js imports any other local file, copying next.config.js is not enough (as the other file needs to be copied as well).

This led to our CI silently deploying a broken build to production (sometimes) which then failed with hard to understand errors.

There are a couple of possible fixes, and I'm not sure which one is better:

  • remove timeout for esbuild
  • add esbuild to firebase-tools' dependencies, so bundling does not depend on network speed
  • in fallback, copy all source files to output
  • in fallback, stop the build

cc @jamesdaniels @leoortizz

[REQUIRED] Environment info

firebase-tools: anything after https://github.com/firebase/firebase-tools/commit/e5981f2e0f40ff87139039cb5ac5004231f2e69f (11.30.0+)

Platform: any

[REQUIRED] Test case

next.config.js:

require('./other');

module.exports = {};

other.js:

[REQUIRED] Steps to reproduce

  • flush npm/npx cache: rm -rf "$(npm config get cache)/_npx"
  • run env FIREBASE_CLI_EXPERIMENTS=webframeworks firebase deploy
  • loop until fails

[REQUIRED] Expected behavior

It works

[REQUIRED] Actual behavior

SSR is deployed but fails at runtime.

Workaround

The simplest workaround is to add esbuild to your project's dependencies. This will cause npx to use project-installed version, so it can't timeout due to network

rasendubi avatar Jul 27 '23 16:07 rasendubi

Hey @rasendubi, thanks for reporting. I discussed this with @alexastrum and we decided to increase the timeout to 60 seconds to workaround the network issues. It will be available in the next release.

leoortizz avatar Aug 02 '23 22:08 leoortizz

Hey @leoortizz. Increasing the timeout doesn't sound like a solution.

It surely decreases the chance of failure but I still don't like that there is a 0.1% chance that it will silently deploy crap instead of my app. I would like to reopen the issue to get it fixed.

What are the downsides to removing the timeout completely or adding esbuild as dependency? I know timeouts were introduced to prevent hang-up, but I would rather enjoy CI hang-up than production outage.

rasendubi avatar Aug 02 '23 22:08 rasendubi

@rasendubi I understand, I'll follow up with @alexastrum for a long-term solution for this issue

leoortizz avatar Aug 02 '23 23:08 leoortizz

Thank you! Could you please reopen the issue meanwhile?

rasendubi avatar Aug 04 '23 10:08 rasendubi

@leoortizz could you reopen or should I open a new issue?

rasendubi avatar Aug 11 '23 13:08 rasendubi

Hey @rasendubi, are you still having this issue?

leoortizz avatar Jun 18 '24 19:06 leoortizz

Hey @rasendubi. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Jul 09 '24 01:07 google-oss-bot

I have applied the workaround locally (added esbuild to my dependencies), so I cannot comment on whether the issue has been fixed or not.

rasendubi avatar Jul 09 '24 06:07 rasendubi

@rasendubi this issue should have been fixed by #7395 would you mind trying it out with the latest version of Firebase CLI and confirm if the issue has been resolved?

chalosalvador avatar Aug 22 '24 07:08 chalosalvador

I no longer work on that project, so I cannot test.

I looked through #7395 and it looks like it fixes the issue by removing timeout. The worrying catch1 that proceeds to deploy broken build is still in place though.

rasendubi avatar Aug 22 '24 08:08 rasendubi