3.18.4
OS X
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.
I expect it to launch the local functions server without erroring.
=== 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.
Could you share your functions code?
My functions code is an Express app, the whole thing is on Github here: https://github.com/jplew/mongodb-firebase-api/blob/master/src/index.ts
However, I just tested by replacing my code with a simple function like this:
export const api = functions.https.onRequest((req, res) => {
res.send('Does this work?')
})
And this failed with the same error: [2018-05-15T19:40:08.801Z] 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
Have same issue (tried to start old project). Environment mostly same (3.18.4, MacOS, NodeJS 10.1.0)
I suppose the problem is with NodeJS. Will try to switch to 6.11.5
Yes, I was right: In recent version of NodeJS noAssert argument of writeInt32LE was removed (was https://nodejs.org/docs/latest-v6.x/api/buffer.html#buffer_buf_writeint32le_offset_noassert now https://nodejs.org/api/buffer.html#buffer_buf_writeint32le_value_offset)
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)
I tried this, on line 189 :
data.writeUInt32LE(_crc & 0xFFFF, Constants.LOCCRC);
But the error remains
@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?
Thank you !
I replaced:
data.writeInt32LE(_crc, Constants.CENCRC, true);
by
data.writeInt32LE(_crc & 0xFFFF, Constants.CENCRC, true);
In the function entryHeaderToBinary, @ C:Program Filesnodejsprojectnode_modulesadm-zipheadersentryHeader.js:217:12
And now it works :)
Same problem on Windows 10 with Node v10.5.0 and [email protected]. The monkey patch works great. Thank you @olostan and @dtruffaut
Problem solved on MacOS with Node v10.5.0. I edited ~/.npm-packages/lib/node_modules/firebase-tools/node_modules/adm-zip/headers/entryHeader.js .
When will this be fixed in a new firebase-tools release?
Worked for me on MacOS with v10.2.1
/usr/local/lib/node_modules/firebase-tools/node_modules/adm-zip/headers/entryHeader.js
I'm just going to point out that this is an exceedingly time-consuming problem to diagnose for newcomers to Firebase.
A fix would be good, but even better might be to have some instructions on how to set up a version of node 8 and run Functions with that version specifically (using e.g. nvm)
Also helpful would be more diagnostic errors that indicate something is not working right.
Thanks for your feedback, we do already document how to set up Node, and recommend nvm to manage versions (https://firebase.google.com/docs/functions/get-started#set-up-nodejs-and-the-firebase-cli). Node 10 not working with the emulator is unintentional and you can follow along the 2 linked bugs above for progress.
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.

@sambegin I'll downgrade to your version and hopefully it works; as it has for you.
Even with the "engines": {"node": "8"}, line in functions/package.json, I still get
Warning: You're using Node.js v8.11.4 but Google Cloud Functions only supports v6.11.5.
What am I missing?
@rtm "engines": {"node": "8"} indicates what Node.js runtime you would like your deployed functions to run in. It is not related to the emulator. What I meant earlier is that local emulation does not yet work with Node 10 if that's what you have on your local machine.
It seems like you have Node v8.11.4 based on the warning message, so you are on a compatible local Node version. Your error might be due to something else. To start with, can you update your firebase-tools to make sure you have the latest version? Run npm install -g firebase-tools. if you are still running into issues, please file a separate issue, and follow the issues template.
I'm currently getting this error message with Node 8.12.0 running. I cannot downgrade to Node 6, because our project uses async functions. The "failed to emulate" message is occurring for all functions, whether they use Express or not.
Most helpful comment
Thank you !
I replaced:
by
In the function entryHeaderToBinary, @ C:Program Filesnodejsprojectnode_modulesadm-zipheadersentryHeader.js:217:12
And now it works :)