serverless: Unexpected end of JSON input in v2.2. Cant sls deploy
I’m not understanding why I couldn’t sls deploy ?
below is my serverless.yml
service: image-upload-s3-dynamodb
frameworkVersion: '2'
provider:
name: aws
runtime: nodejs12.x
lambdaHashingVersion: 20201221
apiGateway:
shouldStartNameWithService: true
stage: dev
region: ap-south-1
functions:
hello:
handler: handler.hello
events:
- httpApi:
path: /users/create
method: get
and as of now I havent changed anything in my lambda handler. Infact this is the basic sls create -t aws-nodejs that I’m trying to deploy is giving me the following error:
simple-git deprecation notice: git.silent: logging should be configured using the `debug` library / `DEBUG` environment variable, this will be an error in version 3
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Syntax Error -------------------------------------------
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at module.exports (C:\Users\Rahul\AppData\Roaming\npm\node_modules\serverless\lib\utils\eventuallyUpdate.js:127:53)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: win32
Node Version: 14.0.0
Framework Version: 2.22.0
Plugin Version: 4.4.2
SDK Version: 2.3.2
Components Version: 3.6.2
I never faced this issue earlier version so could anyone explain me what’s wrong here and what should I do?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (8 by maintainers)
Credits in this case should go to @medikoo 🎉 Happy to hear that and hope you’re gonna have a great time using Serverless Framework @MeRahulAhire 🥳
got it, thank you for pointing out!
Hello @MeRahulAhire, thanks for reporting your issue. It seems like the problem was with https://github.com/serverless/serverless/blob/a11a43c5d2d770ca2df849408dad10fe6de95c38/lib/utils/eventuallyUpdate.js#L106 where the request could potentially return invalid JSON. Does the problem persist for you? I’ve just checked that logic and it works correctly, but I think we could potentially try to catch JSON parsing errors and throw a more meaningful error in such cases.
Please let me know 🙇