firebase / firebase-tools

The Firebase Command Line Tools
MIT License
4.01k stars 929 forks source link

Redeploying existing firebase functions fails. Enters infinite "Starting compilation in watch mode..." #7234

Closed LarryBauman closed 4 months ago

LarryBauman commented 4 months ago

[REQUIRED] Environment info

firebase-tools: 13.10.2

Platform: Windows

[REQUIRED] Test case

Try to redeploy an existing firebase v1 Typescript function.

[REQUIRED] Steps to reproduce

Have a working deployed v1 Typescript function Install Java on machine (necessary for emulating cloud storage) Try to redeploy a change to existing function with firebase deploy --only functions

[REQUIRED] Expected behavior

Function builds and deploys

[REQUIRED] Actual behavior

Build starts as normal with: image

Then enters endless "watching for changes" image

aalej commented 4 months ago

Hey @LarryBauman, thanks for reaching out. Looking at the log messages you shared, it seems like your predeploy script may be running tsc --watch, which compiles your code every time there are file changes, instead of tsc.

Could you check your src/package.json file if scripts.build is set to "tsc --watch"? If so, does changing it to tsc solve the issue? The package.json file would look like:

{
 "name": "functions",
 ...
 "scripts": {
   "lint": "eslint --ext .js,.ts .",
   "build": "tsc",
   "build:watch": "tsc --watch",
   "serve": "npm run build && firebase emulators:start --only functions",
   "shell": "npm run build && firebase functions:shell",
   "start": "npm run shell",
   "deploy": "firebase deploy --only functions",
   "logs": "firebase functions:log"
 },
 ...
}

If the issue still persists after doing so, could you please share a minimal reproducible example with us, or detailed steps on how you set up your project? This will help us accurately replicate the issue.

LarryBauman commented 4 months ago

Hi @aalej thank you for the quick reply and solution. --watch was added to the build line, after removing it, everything works.

 "scripts": {
   "lint": "eslint --ext .js,.ts .",
   "build": "tsc --watch",
   "build:watch": "tsc --watch",
   "serve": "npm run build && firebase emulators:start --only functions",
   "shell": "npm run build && firebase functions:shell",
   "start": "npm run shell",
   "deploy": "firebase deploy --only functions",
   "logs": "firebase functions:log"
 },