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

Deploying functions extremely slow

Open BenjaVR opened this issue 9 years ago • 107 comments

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

BenjaVR avatar Nov 14 '17 10:11 BenjaVR

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.

laurenzlong avatar Nov 14 '17 18:11 laurenzlong

@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.

ddobby94 avatar Nov 25 '17 15:11 ddobby94

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

thomasfischersm avatar Nov 26 '17 01:11 thomasfischersm

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.

thomasfischersm avatar Nov 28 '17 02:11 thomasfischersm

@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).

laurenzlong avatar Nov 28 '17 22:11 laurenzlong

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.

thomasfischersm avatar Nov 28 '17 23:11 thomasfischersm

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.

laurenzlong avatar Dec 01 '17 19:12 laurenzlong

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.

Kyrio avatar Dec 02 '17 15:12 Kyrio

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

davidaik avatar Dec 03 '17 18:12 davidaik

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!

silvafacundo avatar Dec 04 '17 06:12 silvafacundo

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.

miyurusagarage avatar Dec 14 '17 07:12 miyurusagarage

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

teddy-codes avatar Dec 20 '17 22:12 teddy-codes

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

thomasfischersm avatar Dec 20 '17 22:12 thomasfischersm

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

srinurp avatar Dec 28 '17 10:12 srinurp

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 :rofl: :lollipop: :+1: :1st_place_medal: :coffin: :tada: :taco: :cactus: :dancer: :smiling_imp:

merlinnot avatar Dec 28 '17 13:12 merlinnot

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"

teddy-codes avatar Dec 28 '17 13:12 teddy-codes

@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

laurenzlong avatar Dec 28 '17 18:12 laurenzlong

@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?

merlinnot avatar Dec 28 '17 19:12 merlinnot

@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

laurenzlong avatar Dec 28 '17 19:12 laurenzlong

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

merlinnot avatar Dec 28 '17 19:12 merlinnot