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

Firebase deploy deploying all functions even if nothing changed

Open iq-dot opened this issue 1 year ago • 0 comments

firebase-tools: 12.9 firebase: 10.5

Platform: Linux

[REQUIRED] Test case create v1 function and put in folder1 create another v1 function and put in folder2 create index.js at src/ import func1 and func2 and export as { api: { func1, func2 } } Set your deploy command to firebase deploy --project ${npm_config_project} --force [REQUIRED] Steps to reproduce Deploy functions Make no changes and redeploy functions [REQUIRED] Expected behavior Should not redeploy anything the second time if no changes

[REQUIRED] Actual behavior All functions are deployed

This is a re-open of this issue: https://github.com/firebase/firebase-tools/issues/6634

Further details on why:

Hello I am reopening this as removing the --force flag does not help at all, in fact I have seen it can skip deployments even with the --force flag.

I am struggling to debug this and the only 3 things I can point to based on the hashing code that firebase-tools use:

  • the code output after typescript and esbuild is different each time (could not replicate locally)
  • the env variables are somehow different
  • the JSONification of the env variables the firebase tools uses is not always in the same order
  • the Circle CI environment is somehow affecting things

I have tried to SSH into my CI build machines and running the command manually, running once, deploys it all (even though nothing has changed), however if I run it again then it does skip deployment.

Here are my esbuild config:

import * as esbuild from 'esbuild'

const args = process.argv.slice(2)
const watch = args.includes('--watch') || false

const ctx = await esbuild.context({
  entryPoints: ['./build/index.js'],
  bundle: true,
  minify: true,
  outdir: 'dist',
  platform: 'node',
  target: 'node16',
  format: 'esm',
  external: ['./node_modules/*'],
});

if (watch) {
  await ctx.watch()
  console.log('watching...')
} else {
  await ctx.rebuild()
  await ctx.dispose()
  console.log('build done')
}

This is my tsconfig:

{
  "extends": "@tsconfig/node16/tsconfig.json",
  "compilerOptions": {
  "module": "ES2022", 
  "resolveJsonModule": true,
  "outDir": "./build/",
    "include": ["src/**/*"],
    "exclude": ["src/**/*.test.ts", "**/__mocks__/**/*", "**/node_modules/**/*"],
  }

Any help on getting to the bottom of this is really appreciated as our deploys are very slow due full deployments.

iq-dot avatar Mar 14 '24 16:03 iq-dot