Repository navigation
Closed
Description
This is a (Bug Report / Feature Proposal)
Bug
Description
For bug reports:
- What went wrong?
⟩ serverless deploy
{}
Serverless: Bundling with Webpack...
Time: 637ms
Asset Size Chunks Chunk Names
index.js 4.32 kB 0 [emitted] main
[0] ./handler.js 1.57 kB {0} [built]
[1] external "firebase-admin" 42 bytes {0} [not cacheable]
[2] external "firebase-functions" 42 bytes {0} [not cacheable]
Syntax Error -------------------------------------------
Unexpected end of JSON input
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Forums: forum.serverless.com
Chat: gitter.im/serverless/serverless
Your Environment Information -----------------------------
OS: darwin
Node Version: 9.3.0
Serverless Version: 1.25.0
- What did you expect should have happened?
Deployed correctly
- What was the config you used?
service: wrud
provider:
name: google
runtime: nodejs
project: XXXX
credentials: ~/.gcloud/XXXX.json
plugins:
- serverless-google-cloudfunctions
- serverless-webpack
custom:
webpackIncludeModules:
packagePath: './package.json'
# needs more granular excluding in production as only the serverless provider npm
# package should be excluded (and not the whole node_modules directory)
package:
exclude:
- node_modules/**
- .gitignore
- .git/**
functions:
hello:
handler: helloWorld
events:
- http: path
- What stacktrace or error message from your provider did you see?
Stack Trace --------------------------------------------
SyntaxError: Unexpected end of JSON input
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at BbPromise.try (/Users/work1/Projects/wrud/wrud/node_modules/serverless-webpack/lib/packExternalModules.js:236:47)
at tryCatcher (/Users/work1/Projects/wrud/wrud/node_modules/bluebird/js/release/util.js:16:23)
at Function.Promise.attempt.Promise.try (/Users/work1/Projects/wrud/wrud/node_modules/bluebird/js/release/method.js:39:29)
at BbPromise.fromCallback.then.depJson (/Users/work1/Projects/wrud/wrud/node_modules/serverless-webpack/lib/packExternalModules.js:236:35)
at tryCatcher (/Users/work1/Projects/wrud/wrud/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/work1/Projects/wrud/wrud/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/work1/Projects/wrud/wrud/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/Users/work1/Projects/wrud/wrud/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/work1/Projects/wrud/wrud/node_modules/bluebird/js/release/promise.js:693:18)
at Promise._fulfill (/Users/work1/Projects/wrud/wrud/node_modules/bluebird/js/release/promise.js:638:18)
at /Users/work1/Projects/wrud/wrud/node_modules/bluebird/js/release/nodeback.js:42:21
at childProcess.exec (/Users/work1/Projects/wrud/wrud/node_modules/serverless-webpack/lib/packExternalModules.js:233:16)
at ChildProcess.exithandler (child_process.js:279:5)
at ChildProcess.emit (events.js:159:13)
at maybeClose (internal/child_process.js:943:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
From previous event:
at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:368:22)
at PluginManager.spawn (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:386:17)
at ServerlessWebpack.BbPromise.bind.then.then.then (/Users/work1/Projects/wrud/wrud/node_modules/serverless-webpack/index.js:90:51)
at runCallback (timers.js:773:18)
at tryOnImmediate (timers.js:734:5)
at processImmediate [as _immediateCallback] (timers.js:711:5)
Additional Data
package.json
{
"name": "google-nodejs",
"version": "0.1.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "serverless.com",
"license": "MIT",
"dependencies": {
"babel-runtime": "^6.26.0",
"firebase-admin": "^5.8.0",
"firebase-functions": "^0.8.0",
"jsonschema": "^1.2.2",
"serverless-google-cloudfunctions": "^1.1.1"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-3": "^6.24.1",
"eslint": "^4.15.0",
"eslint-config-standard": "^11.0.0-beta.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^5.2.1",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-standard": "^3.0.1",
"serverless-webpack": "^4.2.0",
"webpack": "^3.10.0",
"webpack-node-externals": "^1.6.0"
}
}
- Serverless-Webpack Version you're using: 4.2.0
- Webpack version you're using: 3.10.0
- Serverless Framework Version you're using: 1.25.0
- Operating System: OSX 10.13.2 (17C88) High Sierra
- Stack Trace (if available):
Activity
HyperBrain commentedon Jan 17, 2018
Hi @gastonmorixe, thanks for reporting.
According to the stacktrace, the plugin crashed, because it got an invalid output from the
npm ls -prod -json -depth=1command execution.Can you try to execute it manually and post the output, so that we can check what exactly is going wrong there?
gastonmorixe commentedon Jan 17, 2018
@HyperBrain sure ! https://transfer.sh/LX0S2/serverless_error.log
gastonmorixe commentedon Jan 17, 2018
@HyperBrain also
gastonmorixe commentedon Jan 17, 2018
@HyperBrain sorry to add more comments, it seems that with
npm installinstead ofyarnI get thisHyperBrain commentedon Jan 17, 2018
Thanks a lot. It seems that exactly the same happens during execution of the plugin (there might be a bug in the plugin that prevents noticing the npm error and so the parser fails in the end).
I will try if I get some time tomorrow, so that I can prepare exactly the same package.json, so that I can try to find out why npm fails here. (currently the plugin is based entirely on npm internally). I'll let you know if I found out anything.
gastonmorixe commentedon Jan 18, 2018
I moved to
firebase-clitool. It seems even with all the dependencies solved, it still not working.alopes commentedon Jan 21, 2018
Hey, I believe I might be having the same issue. Works fine running locally with $sls offline start but once I try to deploy it I get that same error. Any ideas on how to tackle this issue?
Thanks
Offline version
package.json
alopes commentedon Jan 21, 2018
Looks like this is caused by using yarn.
By deleting node_modules and then using npm, it works fine.
HyperBrain commentedon Jan 21, 2018
Hi @alopes . Thanks for the information and verification.
I think, having #286 done would make these cases very rare, as the plugin can then be configured to the packager that the user normally uses in his environment.
shwanton commentedon Feb 6, 2018
Just got caught by this while using
yarn, there is section in the README aboutyarnthat I missed.HyperBrain commentedon Feb 7, 2018
@shwanton The section has been added just a few days ago ;-)
samwiseduzer commentedon Feb 20, 2018
I"m having this problem without using yarn, with identical results to @alopes
HyperBrain commentedon Feb 27, 2018
@samwiseduzer Can you check your npm version and try to delete the npm cache (see
npm cache --help)samwiseduzer commentedon Feb 27, 2018
Deleting and reinstalling my packages seemed to take care of this
Drop nodegit, use lambda-git instead
Drop nodegit, use lambda-git instead
Drop nodegit, use lambda-git instead (#6)
samwiseduzer commentedon Mar 3, 2018
I ran into this problem again because of unmet peer dependencies (which I discovered after running "npm ls -prod -json -depth=1"). Fixing the peer dependency took care of the issue for me.
HyperBrain commentedon Mar 14, 2018
@alopes Yarn support is available in
masternow and will be part of the next release. Please give it a try and check if it now correctly handlesyarn.lockand works with yarn as expected. The README inmastercontains the exact steps on how to configure it - and adjust the webpack plugin configuration inserverless.ymlproperly to the new format.HyperBrain commentedon Mar 14, 2018
Update: Yarn support is just released with 5.1.0 💥
HyperBrain commentedon Mar 14, 2018
@gastonmorixe Is there any update for this issue on your side. In case you use yarn, you could try plugin version 5.1.0 and configure it to use yarn as packager (if you don't use it, you can try that too ;-) ).
gastonmorixe commentedon Mar 14, 2018
HyperBrain commentedon Mar 15, 2018
Ok. I'm closing the issue now. Feel free to continue here if needed 😄
HyperBrain commentedon Apr 25, 2018
@gastonmorixe @alopes I finally found the root cause for the original
Unexpected end of JSONerror. It was an improper error messaging and internally a buffer overflow of the stdio buffers when usingchild_process.exec. With #373 I switched the packager invocations to usechild_process.spawnnow. This function uses streams to transfer the stdio stream data to the parent process as opposed to exec which uses fixed buffers (that are broken in some environments).The fix will be released soon with version 5.1.2. If you have some time, you can check out if the current master branch works for you.