firebase-tools: firebase serve fails: Failed to emulate

Version info

3.18.4

Platform Information

OS X

Steps to reproduce

firebase serve

This appears to be a project-specific error. It fails for this particular project, but works for another Firebase functions emulation on the same machine.

firebase functions:shell

This fails with the exact same error.

Expected behavior

I expect it to launch the local functions server without erroring.

Actual behavior

=== Serving from '/Users/govinda/Sites/projects/myproject/api'...

i  functions: Preparing to emulate functions.
[2018-05-15T15:14:16.366Z] Fetching environment
[2018-05-15T15:14:16.367Z] >>> HTTP REQUEST GET https://mobilesdk-pa.googleapis.com/v1/projects/621390543804:getServerAppConfig

Tue May 15 2018 08:14:16 GMT-0700 (PDT)
[2018-05-15T15:14:16.980Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Tue, 15 May 2018 15:14:16 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=hq=":443"; ma=2592000; quic=51303433; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-15T15:14:16.980Z] Starting @google-cloud/functions-emulator
Warning: You're using Node.js v10.1.0 but Google Cloud Functions only supports v6.11.5.
[2018-05-15T15:14:32.852Z] Parsing function triggers
[2018-05-15T15:14:40.952Z] Error while deploying to emulator: RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received 2408773848
RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received 2408773848
    at checkInt (internal/buffer.js:35:11)
    at writeU_Int32LE (internal/buffer.js:515:3)
    at Buffer.writeInt32LE (internal/buffer.js:684:10)
    at Object.entryHeaderToBinary (/usr/local/lib/node_modules/firebase-tools/node_modules/adm-zip/headers/entryHeader.js:216:18)
    at Object.packHeader (/usr/local/lib/node_modules/firebase-tools/node_modules/adm-zip/zipEntry.js:260:39)
    at /usr/local/lib/node_modules/firebase-tools/node_modules/adm-zip/zipFile.js:198:41
    at Array.forEach (<anonymous>)
    at Object.compressToBuffer (/usr/local/lib/node_modules/firebase-tools/node_modules/adm-zip/zipFile.js:182:23)
    at Object.writeZip (/usr/local/lib/node_modules/firebase-tools/node_modules/adm-zip/adm-zip.js:454:32)
    at client.generateUploadUrl.then.then (/usr/local/lib/node_modules/firebase-tools/node_modules/@google-cloud/functions-emulator/src/cli/controller.js:168:13)
⚠  functions: Failed to emulate api

What do value and range represent? Apparently I’m out of it.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 10
  • Comments: 19 (3 by maintainers)

Most upvoted comments

Thank you !

I replaced:

data.writeInt32LE(_crc, Constants.CENCRC, true);

by

data.writeInt32LE(_crc & 0xFFFF, Constants.CENCRC, true);

In the function entryHeaderToBinary, @ C:\Program Files\nodejs\project\node_modules\adm-zip\headers\entryHeader.js:217:12

And now it works 😃

Ok, (temporary) solution is to monkey-patch adm-zip library by adding & 0xFFFF on line 198 to _crc (edit /usr/lib/node_modules/firebase-tools/node_modules/adm-zip/headers/entryHeader.js)

When will this be fixed in a new firebase-tools release?

It seems to work with node 10.3.0 without the monkey patch on MacOS… for those who’d like to stay at least on version 10. screen shot 2018-08-14 at 6 02 34 pm

@dtruffaut make sure you’re changed correct file and it was not overwritten. Inspect your error message, it should specify location of the file to edit and line (just after packHeader). This patch fixes “The value of “value” is out of range” error. May be you have some another?