Question

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
node:events:368
node:events:368
      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
Answer a question...

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.

Cheers

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!

Best,

Bobby