doctl -v serverless deploy results in "Error: unexpected end of JSON"

Hi, the question kind of tells the whole story. When trying to run a serverless deploy, I’m getting constant errors I can’t explain. I’ve reverted back to previous code version where it has deployed successfully so I don’t think it’s related to the actual code or project.yaml. When I try to use watch to auto-deploy, I see the following error throw:

 % doctl -v serverless watch .
Watching '.' [use Control-C to terminate]

Deploying '.' due to change in 'packages/x/y/index.js'
Started running npm install --production in xxxxxxxxx
Started running npm install --production in xxxxxxxxx
Started running npm install --production in xxxxxxxxx
Started running npm install --production in xxxxxxxxx
Started running npm install --production in yyyyyyyyy
      throw er; // Unhandled 'error' event

Error: read ECONNRESET
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:220:20)
Emitted 'error' event on ClientRequest instance at:
    at TLSSocket.socketErrorListener (node:_http_client:447:9)
    at TLSSocket.emit (node:events:390:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -54,
  code: 'ECONNRESET',
  syscall: 'read'
Error: exit status 1

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Well it all just fixed itself and stated working 🤔. I therefore think it was something environmental outside of my control. I made no code changes and no known configuration changes either, just walked away for a few days before trying again.

In case anyone else finds this in the future, for me running doctl serverless deploy . resulted in only Error: unexpected end of JSON, nothing more.

I didn’t get to try the remote build option while local builds were failing, since local builds just worked (again). Now both work.

I did notice that the STDOUT of the deploy and watch commands are now different in my shell than before the build command failed, so there must have been some changes on the DO side of things.


Bobby Iliev
Site Moderator
Site Moderator badge
December 10, 2022

Hi there,

Does it work if you run it without the watch flag?

Also, I could suggest is trying to add the --remote-build parameter to your command, eg.:

doctl -v serverless watch . --remote-build

Let me know how it goes!



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.