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

Deploying functions extremely slow #536

Closed
BenjaVR opened this issue Nov 14, 2017 · 107 comments
Closed

Deploying functions extremely slow #536

BenjaVR opened this issue Nov 14, 2017 · 107 comments
Assignees

Comments

@BenjaVR
Copy link

BenjaVR commented Nov 14, 2017

Version info

3.15.0

Steps to reproduce

Make a simple functions directory with only 1 function:

const functions = require('firebase-functions');
const admin = require('firebase-admin');

admin.initializeApp(functions.config().firebase);

exports.ping = functions.https.onRequest((req, res) => {
  res.status(200).send('pong');
}

Now deploy using firebase deploy --only functions.

Expected behavior

Deploy faster. Now it takes minutes to deploy a small functions file. If I compare this to the hosting upload/deploy, that one goes pretty fast and is much more then one file.

Actual behavior

Takes extremely long to upload/deploy. It hangs during the preparing functions directory for uploading... phase.

image

Debug log for firebase deploy --only functions:
please note I used another function then in my reproduce step, but it's the same idea: a small function with only a few lines of code.

> firebase deploy --only functions --debug
[2017-11-14T10:03:55.799Z] ----------------------------------------------------------------------
[2017-11-14T10:03:55.804Z] Command:       C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\firebase-tools\bin\firebase deploy --only functions --debug
[2017-11-14T10:03:55.806Z] CLI Version:   3.15.0
[2017-11-14T10:03:55.806Z] Platform:      win32
[2017-11-14T10:03:55.806Z] Node Version:  v6.11.1
[2017-11-14T10:03:55.807Z] Time:          Tue Nov 14 2017 04:03:55 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:03:55.807Z] ----------------------------------------------------------------------

[2017-11-14T10:03:55.826Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2017-11-14T10:03:55.827Z] > authorizing via signed-in user
[2017-11-14T10:03:55.831Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/marktec-itesm
 Tue Nov 14 2017 04:03:55 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:03:56.230Z] <<< HTTP RESPONSE 200 server=nginx, date=Tue, 14 Nov 2017 10:03:57 GMT, content-type=application/json; charset=utf-8, content-length=108, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store
[2017-11-14T10:03:56.232Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/database/marktec-itesm/tokens
 Tue Nov 14 2017 04:03:56 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:03:56.622Z] <<< HTTP RESPONSE 200 server=nginx, date=Tue, 14 Nov 2017 10:03:57 GMT, content-type=application/json; charset=utf-8, content-length=262, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store

=== Deploying to 'marktec-itesm'...

i  deploying functions
[2017-11-14T10:03:57.040Z] > [functions] package.json contents: {
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "serve": "firebase serve --only functions",
    "shell": "firebase experimental:functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "dependencies": {
    "firebase-admin": "~5.4.2",
    "firebase-functions": "^0.7.1"
  },
  "private": true
}
i  functions: ensuring necessary APIs are enabled...
i  runtimeconfig: ensuring necessary APIs are enabled...
[2017-11-14T10:03:57.043Z] >>> HTTP REQUEST GET https://servicemanagement.googleapis.com/v1/services/cloudfunctions.googleapis.com/projectSettings/marktec-itesm?view=CONSUMER_VIEW
 Tue Nov 14 2017 04:03:57 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:03:57.044Z] >>> HTTP REQUEST GET https://servicemanagement.googleapis.com/v1/services/runtimeconfig.googleapis.com/projectSettings/marktec-itesm?view=CONSUMER_VIEW
 Tue Nov 14 2017 04:03:57 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:03:57.479Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
Origin,Accept-Encoding, date=Tue, 14 Nov 2017 10:03:58 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
+  functions: all necessary APIs are enabled
[2017-11-14T10:03:57.488Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
Origin,Accept-Encoding, date=Tue, 14 Nov 2017 10:03:58 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
+  runtimeconfig: all necessary APIs are enabled
[2017-11-14T10:03:57.489Z] >>> HTTP REQUEST GET https://appengine.googleapis.com/v1/apps/marktec-itesm
 Tue Nov 14 2017 04:03:57 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:03:57.490Z] >>> HTTP REQUEST GET https://apikeys.googleapis.com/v1/projects/marktec-itesm/apiKeys
 Tue Nov 14 2017 04:03:57 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:03:57.775Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
Origin,Accept-Encoding, date=Tue, 14 Nov 2017 10:03:58 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
[2017-11-14T10:03:57.950Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
Origin,Accept-Encoding, date=Tue, 14 Nov 2017 10:03:58 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
i  functions: preparing functions directory for uploading...
[2017-11-14T10:05:52.258Z] >>> HTTP REQUEST GET https://runtimeconfig.googleapis.com/v1beta1/projects/marktec-itesm/configs
 Tue Nov 14 2017 04:05:52 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:05:52.676Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
Origin,Accept-Encoding, date=Tue, 14 Nov 2017 10:05:53 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
i  functions: packaged functions (22.1 KB) for uploading
[2017-11-14T10:06:01.593Z] >>> HTTP REQUEST GET https://www.googleapis.com/storage/v1/b/staging.marktec-itesm.appspot.com
 Tue Nov 14 2017 04:06:01 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:06:01.940Z] <<< HTTP RESPONSE 200 x-guploader-uploadid=AEnB2UpSfip_C_K1wvCJaLNVW1q05_zW3D3fph0U7sYHr6_9M5InFI0Pi_X1VFc8B5PpbZImDdZiAaZZLqWXdl-JxdzedIZeExTeX4ifDbfvg7G8tsjPm1Y, etag=CAE=, vary=Origin, X-Origin, content-type=application/json; charset=UTF-8, expires=Tue, 14 Nov 2017 10:06:02 GMT, date=Tue, 14 Nov 2017 10:06:02 GMT, cache-control=private, max-age=0, must-revalidate, no-transform, content-length=548, server=UploadServer, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", connection=close
[2017-11-14T10:06:01.942Z] >>> HTTP REQUEST POST https://www.googleapis.com/upload/storage/v1/b/staging.marktec-itesm.appspot.com/o?uploadType=media&name=firebase-functions-source ReadStream {
  _readableState:
   ReadableState {
     objectMode: false,
     highWaterMark: 65536,
     buffer: BufferList { head: [Object], tail: [Object], length: 1 },
     length: 22627,
     pipes: null,
     pipesCount: 0,
     flowing: null,
     ended: true,
     endEmitted: false,
     reading: false,
     sync: false,
     needReadable: false,
     emittedReadable: true,
     readableListening: false,
     resumeScheduled: false,
     defaultEncoding: 'utf8',
     ranOut: false,
     awaitDrain: 0,
     readingMore: false,
     decoder: null,
     encoding: null },
  readable: true,
  domain: null,
  _events: { end: [Function] },
  _eventsCount: 1,
  _maxListeners: undefined,
  path: 'C:\\Users\\benja\\AppData\\Local\\Temp\\firebase-functions-69565Vb7CkPZp0rr.zip',
  fd: 6,
  flags: 'r',
  mode: 438,
  start: undefined,
  end: undefined,
  autoClose: true,
  pos: undefined,
  bytesRead: 22627 }
 Tue Nov 14 2017 04:06:01 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:06:02.601Z] <<< HTTP RESPONSE 200 x-guploader-uploadid=AEnB2UqV_ml27ZAt9W3ouCst97NUKPW4MeltDmxl06PA4sGBy6A8fqo0bAbEKHT0vokHMXo0t0yhOY0ve3XT0RrLjsiDwXyhwA, etag=CJPx8MbovdcCEAE=, vary=Origin, X-Origin, content-type=application/json; charset=UTF-8, cache-control=no-cache, no-store, max-age=0, must-revalidate, pragma=no-cache, expires=Mon, 01
Jan 1990 00:00:00 GMT, date=Tue, 14 Nov 2017 10:06:03 GMT, content-length=860, server=UploadServer, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", connection=close
+  functions: functions folder uploaded successfully
[2017-11-14T10:06:02.604Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1beta2/projects/marktec-itesm/locations/us-central1/functions
 Tue Nov 14 2017 04:06:02 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:06:02.845Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
Origin,Accept-Encoding, date=Tue, 14 Nov 2017 10:06:03 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
i  functions: updating function verifyItesmDomain...
[2017-11-14T10:06:02.849Z] Trigger is:  resource=projects/marktec-itesm, eventType=providers/firebase.auth/eventTypes/user.create
[2017-11-14T10:06:02.851Z] >>> HTTP REQUEST PUT https://cloudfunctions.googleapis.com/v1beta2/projects/marktec-itesm/locations/us-central1/functions/verifyItesmDomain { sourceArchiveUrl: 'gs://staging.marktec-itesm.appspot.com/firebase-functions-source',
  name: 'projects/marktec-itesm/locations/us-central1/functions/verifyItesmDomain',
  entryPoint: 'verifyItesmDomain',
  timeout: '60s',
  availableMemoryMb: 256,
  labels: { 'deployment-tool': 'cli-firebase' },
  eventTrigger:
   { resource: 'projects/marktec-itesm',
     eventType: 'providers/firebase.auth/eventTypes/user.create' } }
 Tue Nov 14 2017 04:06:02 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:06:03.064Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
Origin,Accept-Encoding, date=Tue, 14 Nov 2017 10:06:03 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
[2017-11-14T10:06:03.068Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1beta2/operations/bWFya3RlYy1pdGVzbS91cy1jZW50cmFsMS92ZXJpZnlJdGVzbURvbWFpbi90SFM4NnhjSF9DUQ
 Tue Nov 14 2017 04:06:03 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:06:03.257Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
Origin,Accept-Encoding, date=Tue, 14 Nov 2017 10:06:04 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
[2017-11-14T10:06:05.262Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1beta2/operations/bWFya3RlYy1pdGVzbS91cy1jZW50cmFsMS92ZXJpZnlJdGVzbURvbWFpbi90SFM4NnhjSF9DUQ
 Tue Nov 14 2017 04:06:05 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:06:05.428Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
Origin,Accept-Encoding, date=Tue, 14 Nov 2017 10:06:06 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
[2017-11-14T10:06:07.431Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1beta2/operations/bWFya3RlYy1pdGVzbS91cy1jZW50cmFsMS92ZXJpZnlJdGVzbURvbWFpbi90SFM4NnhjSF9DUQ
 Tue Nov 14 2017 04:06:07 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:06:07.603Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
Origin,Accept-Encoding, date=Tue, 14 Nov 2017 10:06:08 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
[2017-11-14T10:06:09.606Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1beta2/operations/bWFya3RlYy1pdGVzbS91cy1jZW50cmFsMS92ZXJpZnlJdGVzbURvbWFpbi90SFM4NnhjSF9DUQ
 Tue Nov 14 2017 04:06:09 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:06:09.755Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
Origin,Accept-Encoding, date=Tue, 14 Nov 2017 10:06:10 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
[2017-11-14T10:06:11.757Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1beta2/operations/bWFya3RlYy1pdGVzbS91cy1jZW50cmFsMS92ZXJpZnlJdGVzbURvbWFpbi90SFM4NnhjSF9DUQ
 Tue Nov 14 2017 04:06:11 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:06:11.912Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
Origin,Accept-Encoding, date=Tue, 14 Nov 2017 10:06:12 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
[2017-11-14T10:06:13.913Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1beta2/operations/bWFya3RlYy1pdGVzbS91cy1jZW50cmFsMS92ZXJpZnlJdGVzbURvbWFpbi90SFM4NnhjSF9DUQ
 Tue Nov 14 2017 04:06:13 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:06:14.078Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
Origin,Accept-Encoding, date=Tue, 14 Nov 2017 10:06:14 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
[2017-11-14T10:06:16.080Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1beta2/operations/bWFya3RlYy1pdGVzbS91cy1jZW50cmFsMS92ZXJpZnlJdGVzbURvbWFpbi90SFM4NnhjSF9DUQ
 Tue Nov 14 2017 04:06:16 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:06:16.249Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
Origin,Accept-Encoding, date=Tue, 14 Nov 2017 10:06:17 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
[2017-11-14T10:06:18.252Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1beta2/operations/bWFya3RlYy1pdGVzbS91cy1jZW50cmFsMS92ZXJpZnlJdGVzbURvbWFpbi90SFM4NnhjSF9DUQ
 Tue Nov 14 2017 04:06:18 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:06:18.405Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
Origin,Accept-Encoding, date=Tue, 14 Nov 2017 10:06:19 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
[2017-11-14T10:06:20.406Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1beta2/operations/bWFya3RlYy1pdGVzbS91cy1jZW50cmFsMS92ZXJpZnlJdGVzbURvbWFpbi90SFM4NnhjSF9DUQ
 Tue Nov 14 2017 04:06:20 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:06:20.588Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
Origin,Accept-Encoding, date=Tue, 14 Nov 2017 10:06:21 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
[2017-11-14T10:06:22.591Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1beta2/operations/bWFya3RlYy1pdGVzbS91cy1jZW50cmFsMS92ZXJpZnlJdGVzbURvbWFpbi90SFM4NnhjSF9DUQ
 Tue Nov 14 2017 04:06:22 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:06:22.753Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
Origin,Accept-Encoding, date=Tue, 14 Nov 2017 10:06:23 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
[2017-11-14T10:06:24.768Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1beta2/operations/bWFya3RlYy1pdGVzbS91cy1jZW50cmFsMS92ZXJpZnlJdGVzbURvbWFpbi90SFM4NnhjSF9DUQ
 Tue Nov 14 2017 04:06:24 GMT-0600 (Central Standard Time (Mexico))
[2017-11-14T10:06:24.952Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
Origin,Accept-Encoding, date=Tue, 14 Nov 2017 10:06:25 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
+  functions[verifyItesmDomain]: Successful update operation.

+  Deploy complete!

Project Console: https://console.firebase.google.com/project/marktec-itesm/overview
@laurenzlong
Copy link
Contributor

Thanks for filing! We know that slow deployment is a major pain point for the functions experience, and it is something that we are working to resolve through various strategies.

@ddobby94
Copy link

@laurenzlong
As a newbie to Firebase at first glance I thought I was messing up something, because the deploy always stopped at the functions: preparing functions directory for uploading... part.
Giving some extra info (like: it takes 3-5 minutes to complete) would be really nice, until the problem is solved.

@thomasfischersm
Copy link

As a newbie, I spent many times canceling on this thinking that I was doing something wrong.

@thomasfischersm
Copy link

The problem is kind of obvious. The init command created a 'node modules' folder that is huge. On my machine it is: 22,903 Files, 2,782 Folders. The code copies all of that to a temp folder.

Here is what I did:

  1. Using log print statements, I identified the slow line of code. It is here:
    https://github.com/firebase/firebase-tools/blob/master/lib/prepareFunctionsUpload.js#L26

Line 26 in prepareFunctionsUpload.js:
fs.copySync(options.config.path(options.config.get('functions.source')), tmpdir.name);

  1. I printed out the parameters for that file copy call. On my machine it is:
    C:\Users\thoma\StudioProjects\LSystemAndroid\firestore\functions
    -> C:\Users\thoma\AppData\Local\Temp\fbfn_752624vejX0cv3GEJI

The functions folder was created by the CLI command init. It looks like this:

  • node_modules (enormous size)
  • .gitignore
  • index.js
  • package.json
  • pacakge-lock.json

It seems to me that the CLI command init should NOT have created that node_modules folder. It's 165MB large. That seems unreasonable to add to every project.

@laurenzlong
Copy link
Contributor

@thomasfischersm

That's actually not the issue. The node_modules is not copied over to the temporary folder, as you can see from this line here: https://github.com/firebase/firebase-tools/blob/master/lib/prepareFunctionsUpload.js#L76

It is necessary for firebase init to install all the node modules locally inside of the functions source folder, otherwise locally serving the functions will not work, and trigger extraction will not work (this is how the CLI understands which events trigger each function so it can deploy them properly).

@thomasfischersm
Copy link

I put a debug print line before line 26 and after. That line took minutes.

Then, I added a filter to print out which files were being copied. It included all the node_modules files.

Then, I changed the filter to exclude the node_module files. The deployment progressed fast now. However a little later, it seemed that the script was trying to evaluate the correctness of the cloud functions. That code failed because it was missing the library dependencies.

The source code line that you point to seems to be a later step. It seems like the files (minus the node_modules) are archived into a zip file before uploading to the cloud. That line doesn't seem to run slow on my machine.

@laurenzlong laurenzlong self-assigned this Dec 1, 2017
@laurenzlong
Copy link
Contributor

Yes you're right, I was mistaken, node_modules does get copied over. I think it is a valid idea to not copy over node_modules to the temp directory. What complicates this a bit is the fact that the CLI writes a ".runtimeconfig.json" to the temp folder prior to trigger parsing, and this file gets uploaded with the rest of the functions source code, and we didn't want to write this file into the actual source code directory. So there is probably a good solution that both improves deployment speed and ensures there aren't unintended side effects, but I'd have to play around with a bit. You can also feel free to make a pull request.

@Kyrio
Copy link

Kyrio commented Dec 2, 2017

I'm having the same issue. It might be a good idea to print more messages during the "preparing directory..." steps so that the user doesn't think firebase-tools is hanging.

Edit: This was on Ubuntu WSL. On Linux, the "preparing" phase doesn't hang. The "creating function" step can be slow, but not as much as I experienced earlier.

@davidaik
Copy link

davidaik commented Dec 3, 2017

This issue is a real pain in the bum. I think it should be given high priority :/

@silvafacundo
Copy link

I'm trying to implement firebase functions to my project and because this error I had to postpone it.
This error made me waste a lot of time.
hope it be fixed soon!

@miyurusagarage
Copy link

This issue is a major hindrance. Mostly because I use firestore and in that stuff like aggregates, counters and presence can only be handled decently by cloud functions and it just hangs for 5 minutes every time.

@teddy-codes
Copy link

@PulpoEnPatineta This is not an error. This is just simply an issue with the deploy time.

@thomasfischersm
Copy link

@mcstuffins If your car takes five minutes to turn on, is it an error or simply an issue with start time?

@srinurp
Copy link

srinurp commented Dec 28, 2017

is there a fix for this? It is really extremely slow.

@merlinnot
Copy link
Contributor

I kept track of this issue from the beginning, but it's never been a problem for me since I have a CD set up and it does all the work for me. I also never deploy functions just to test if they work. So basically it didn't matter to me.

Until today, when I came across an unexpected limitation: I cannot deploy my functions anymore, cause deployment to production exceeds the daily quota (12,000 seconds). I have ~55 functions with various triggers (pubsub, firestore, https). Is it too much to handle?

Now I have to deploy my application for two days 🤣 🍭 👍 🥇 ⚰️ 🎉 🌮 🌵 💃 😈

@teddy-codes
Copy link

Sometimes, when I am deploying, it is extremely slow, and then there is a warning in the terminal that says "Error in the build environment"

@laurenzlong
Copy link
Contributor

@srinurp Please see the pull request I linked to above, it will address a part of the problem. And the backend team is working to address other parts of the issue (but it's a very complicated undertaking, so we appreciate your patience.)

@merlinnot Unless you are updating code for all of your functions with each deploy, I would recommend using the --only command to deploy individual functions or groups of functions. See https://firebase.google.com/docs/cli/#partial_deploys.

@mcstuffins "Error in the build environment" usually indicates a production issue, in that case please file a support ticket at https://firebase.google.com/support/, you can see if there are any ongoing production issues by visiting the Firebase Status Dashboard

@merlinnot
Copy link
Contributor

@laurenzlong I would have to configure my CI to automatically detect changes in each function between deployments (including resolving dependencies). And what if I update packages like firebase-functions, firebase-admin, lodash etc., which I use in every single function?

@laurenzlong
Copy link
Contributor

@merlinnot That's a very legitimate use case. Deployment quotas are controlled by the Google Cloud Functions, I would recommend filing a request on their public issues tracker: https://cloud.google.com/functions/docs/support

@merlinnot
Copy link
Contributor

For everyone interested: https://issuetracker.google.com/issues/71385193

@horacehylee
Copy link

@laurenzlong Could node_modules folder be ignored when copying the source and then do a npm install --production or yarn install --production? As these tools may be faster than simply copying and pasting.

@merlinnot
Copy link
Contributor

@horacehylee
This might be a breaking change. Some people may (myself included) still reference packages by a relative path (like "package-name": "./externs/package.tgz"), mostly 'cause of the (now fixed) issue with private repositories. The tool would have to take all of these corner cases into account.

The other thing is the caching: if Google was to download packages on your behalf, they would have to implement some internal caching mechanism. We all have local caches on our computers (both npm and yarn have caching mechanisms), therefore we don't kill npm's servers ;)

Some people might also want to simply test some changes in external libraries. It's much easier to just change a file and deploy the function than it is to create a fork, make changes, temporarily change a reference to the package, ...

Bottom line: it works just fine, leave it as it is now 👍

@laurenzlong
Copy link
Contributor

@horacehylee @merlinnot Thanks for the 2 cents. Please see #578, the next release of the CLI will no longer copy the functions source folder period.

@trekze
Copy link

trekze commented Jan 8, 2018

I'm really not sure what firebase could be doing that takes MINUTES to deploy a 5 line, 1kb function, on a six 4GHz core machine, sitting on a 1Gbps fiber connection.

I know it sounds like I'm taking the piss, but I'm genuinely curious what is going on during "preparing directory for upload". Anyone actually know?

@mbleigh
Copy link
Contributor

mbleigh commented Jan 8, 2018 via email

@trekze
Copy link

trekze commented Jan 8, 2018

@mbleigh

Ah right. that explains it. It's kind of comedic seeing a workstation go crazy for a minute or two, only to have the next line print out "packaged functions (37.55kb !!!) successfully for uploading" lol

Look forward to the next release. Thx for responding.

H.

@prateekchitransh1907
Copy link

prateekchitransh1907 commented Jan 15, 2018

Day 19. Firebase still deploying. * grabs popcorn *

@dinvlad
Copy link

dinvlad commented Jun 25, 2020

That's really sad to hear. Another approach is to bundle multiple entrypoints/routes into a single function. This is not the best from the separation of concerns/size/security obviously, but this is what we did with all of our API endpoints (single entrypoint that then uses an internal router), and haven't experienced many quota limits since (but they do happen occasionally).

Still, this quota limit seems really low, since the official doc lists "80 per 100 seconds" for "Calls to deploy or delete functions via the Cloud Functions API". I'm assuming Google support could not raise this limit even further?

@jsakas
Copy link

jsakas commented Jun 25, 2020

Still, this quota limit seems really low, since the official doc lists "80 per 100 seconds" for "Calls to deploy or delete functions via the Cloud Functions API". I'm assuming Google support could not raise this limit even further?

@dinvlad I was inquiring to both sales and support about getting that API limit increased, it's explicitly disabled / greyed out in the GCP console quotas section. Eventually was able to get a Google engineer on hangouts who informed me "That quota does not change".... so I guess not.

samtstern added a commit that referenced this issue Jun 25, 2020
If a functions-only developer chooses to put their functions source in the root folder, this could be a source of longer deploy times.  See #536
@samtstern
Copy link
Contributor

We have added .git to the standard ignore list in the next release:
#2395

That should speed up releases for some. Of course there's not much we (the Firebase CLI team) can do about latency on the Cloud Functions backend.

@slk333
Copy link

slk333 commented Jun 25, 2020

make sure to do firebase deploy --only hosting when you're not updating functions

@kylecordes
Copy link

Over here we've also been grouping related functionality into a function, so it ends up looking like "one function per feature area” rather than “one function per individual granule of functionality”.

The performance characteristics of deployment are strongly driving the architecture of what goes into one function!

@chriscurnow
Copy link

When and why did this issue get closed. It was opened in Nov 2017 and it looks like it is still just as much a problem as it was then. I can't see a reference to 'Closed' here and I would be interested to know why it was closed.

I'm not complaining, just wondering. I'm sure it's being worked on but it would be good to know about any progress.

@repentsinner
Copy link

@chriscurnow it was closed because the real cause is apparently is due to the (closed-source) server side not the CLI tools, even though it manifests to end users as a CLI issue (per @samtstern in #536 (comment)).

Unfortunately there's no good public tracker for the back end so we get updates here :(

@RenFontes
Copy link

How can we open this bug for google to fix it in their backend?
It is ridiculously slow

Like, what's even the point of using firebase functions if it's going to take this long

@RenFontes
Copy link

Hey guys, maybe we could all report this issue to google and maybe they'll listen?
https://firebase.google.com/support/troubleshooter/contact

Every time I try to use something from google for something important I'm reminded that they are one of the least consumer friendly companies in existence, but hey, we could try.

@repentsinner
Copy link

@RenFontes I just filed Case 00075974: Deploying firebase functions is so slow as to be unusable with Firebase support. I will update this message with whatever they come back with.

@SrBrahma
Copy link

It's possible to deploy specific functions. Couldn't the CLI have a "checksum tracker" for each function and only deploy the changed ones (and also, track everything it uses: vars, packages, ...)?

@repentsinner
Copy link

@SrBrahma sure, but the issue is still present even if you only deploy a single function (e.g., single function deploy can still fail due to timeout).

It shouldn't have to fall on the user to manage batching function deployment, and in many cases function updates are needed atomically, therefore can't be split/batched.

Appreciate the suggestions for a workaround, but really what we need here is an SLA from Google and their adherence to it.

@jc0d3d3v
Copy link

IT is True that Firebase Functions Sometimes?(maybe often) sucks at performance..It is really slow..You should support Rust rather.. Go? is it much faster than Node?

@mgtf
Copy link

mgtf commented Oct 11, 2020

Still waiting for Google to improve Google Functions deploying time right ?
Going from PWA to SSR forced me to wait 7 min more for every deploy 😞

@royappa
Copy link

royappa commented Jan 15, 2021

Deploying the initial helloWorld sample function takes 1 min 40 sec with the above ".ignore" rule (Jan. 2021) so I think it's safe to say this is not a priority for Google to improve.

Just in case this helps any other beginners: run the Firebase emulator, then change "tsc" to "tsc -w" (if using typescript) in package.json, and finally run "npm run build" in another window. With this, the emulator reloads your function changes right away. This makes local development a lot faster than waiting 2 minutes to test changes on Google's servers.

@SrBrahma
Copy link

SrBrahma commented Jan 15, 2021

Deploying the initial helloWorld sample function takes 1 min 40 sec with the above ".ignore" rule (Jan. 2021) so I think it's safe to say this is not a priority for Google to improve.

Just in case this helps any other beginners: run the Firebase emulator, then change "tsc" to "tsc -w" (if using typescript) in package.json, and finally run "npm run build" in another window. With this, the emulator reloads your function changes right away. This makes local development a lot faster than waiting 2 minutes to test changes on Google's servers.

I have made this start script in package.json some time ago, that is incredibly helpful and useful to quickly start the emulator and set tsc watch with a single command:

"start": "tsc --incremental && concurrently 'tsc -w' 'firebase emulators:start --only functions,database,auth --export-on-exit=./localSave --import=./localSave'",

Install concurrently with npm i -D concurrently, it runs multiple commands in parallel and in same terminal. I don't remember now why I added the --incremental flag there in tsc, but it certainly fixed something. Export and import are optional fields to save the state of the emulator to use on other sessions.

I also have the startClean script that removes previous state data:

"startClean": "rm -rf ./functions/localSave && npm run start",

Edit: I think I remembered about the incremental: first we build project with tsc, so when the emulator is started, it's using the latest code. Using incremental prevents that tsc -w rebuilds the project again (taking longer), already done by the first tsc.

@samtstern
Copy link
Contributor

@royappa @SrBrahma thank you for sharing your emulators solutions, one major goal of the emulators is to reduce how often developers have to run firebase deploy! For my personal projects the emulators have totally changed my development experience, I never deploy just to test something now.

@carlpaten
Copy link

carlpaten commented Mar 6, 2021

I'm writing this comment in the midst of a major outage that I'm in charge of fixing. "But @LilRed", you might say, "why are you replying to closed GitHub issues instead of attending to your major outage?"

Because every time I attempt a fix and re-deploy a single Firebase Function, I have to wait and twiddle my thumbs for five minutes and a half before deployment completes and I can see if my fix worked. And maybe I need to make two or three attempts. At this point more than half of our backend incident response time is waiting on Cloud Functions deploys.

@jsakas
Copy link

jsakas commented Mar 6, 2021

@LilRed I would recommend using the functions emulator for testing changes instead of deploying them up. This was our problem too before we configured the emulator for development and testing.

@Scino
Copy link

Scino commented Apr 29, 2021

@RenFontes I just filed Case 00075974: Deploying firebase functions is so slow as to be unusable with Firebase support. I will update this message with whatever they come back with.

Did they get back to you with any solutions? @RenFontes

We're facing the same issue, as even single functions deployment is so slow that creating new functions inevitably fails, unless we force a longer timeoutSeconds in function's runtimeOpts before deploying. That, for instance, is an ugly workaround, but not a real solution.

Also it'd be nice to have more useful error logs for these timeout-related deployment errors, rather than just a Error: Functions did not deploy properly. message. We wasted too much time trying to figure out what could cause the issue by attempts.

@kharaone
Copy link

kharaone commented May 1, 2021

@Scino deployment errors appear in the function logs on the firebase console :) Still sometimes cryptic but gives definitely more insight on the possible root cause

Another workaround that I've found useful is to use a bundle for the final artifacts (webpack, rollup, etc) : source code stays separated but the artifact that you deploy is a bundle of all the functions. Still slow, but you bite the bullet only once :)

I still would like to see a better experience with functions.

@carlpaten
Copy link

Another workaround that I've found useful is to use a bundle for the final artifacts (webpack, rollup, etc) : source code stays separated but the artifact that you deploy is a bundle of all the functions. Still slow, but you bite the bullet only once :)

That sounds promising. Did you have to play around with Google Cloud Build directly or something like that?

@kharaone
Copy link

kharaone commented May 5, 2021

I was using Github Actions at that time. Didn't have to dig into cloud build. But I didn't have a huge amount of function neither (~40)

@repentsinner
Copy link

repentsinner commented May 8, 2021

@RenFontes I just filed Case 00075974: Deploying firebase functions is so slow as to be unusable with Firebase support. I will update this message with whatever they come back with.

Did they get back to you with any solutions? @RenFontes

Not really @Scino. This is what I received from Firebase support, and I didn't follow up further. Nobody on the Firebase/Google team seems to appreciate that every now and then we actually need to push functions to production rather than just play with them in an emulator. Single function uploads often fail, even if they have been tested and validated locally via the emulator. Good luck trying to get multiple updates to push in any sort of atomic way.

I'm Joel, and I'll be happy to assist you here.

Cloud Functions deployments do take some time, and the team is working to reduce the time it takes. However, the next steps might help in case the delay exceeds the usual timing.

Please try the following:
Start with a clean slate. (new directory)
Upgrade to the latest Firebase packages:
firebase i -g firebase-tools@latest
firebase i firebase-functions@latest
firebase i firebase-admin@latest
Try with a "hello world" function with no third party dependencies.
Check that the network is stable. Factors that can affect are internet speed, network glitches, compilation (in case of typescript and/or other tools)
Deploy.
You can deploy only the Functions components with:
firebase deploy --only functions

Even deploying a single function like:
firebase deploy --only functions:my-function

Please use the --debug flag if necessary to troubleshoot any issues (firebase deploy --debug --only functions:my-function)

I hope you find this information useful.

Cheers,
Joel

@algoflows
Copy link

algoflows commented Apr 22, 2022

Anyone had any success using modern bundlers like es-build to bundle and speed up function deployments?

@riordanpawley
Copy link

Anyone had any success using modern bundlers like es-build to bundle and speed up function deployments?

I'm currently doing that. It seems to have slowed down deployments though haha

@mtrabelsi
Copy link

my console is still deploying still 2017, I'm still positive for a fix, i will keep it open

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