serverless-plugins icon indicating copy to clipboard operation
serverless-plugins copied to clipboard

[serverless-offline-dynamodb-streams] ECONNREFUSED on SIGINT

Open cnuss opened this issue 4 years ago • 0 comments

Greetings!

I've spent the better part of the day debugging this but I'm afraid I have hit a wall...

Steps to Reproduce

TL;DR: I've set up a sample repo to demonstrate the issue:

  1. git clone https://github.com/cnuss-test-org-001/microservice-1-sls-rest-api
  2. cd microservice-1-sls-rest-api
  3. yarn
  4. yarn start
  5. once up and running, wait a few seconds, then Ctrl+C to SIGINT

Error from Serverless:

...
offline: [HTTP] server ready: http://localhost:3000 🚀
offline:
offline: Enter "rp" to replay the last request
No issues found.
^C
offline: Got SIGINT signal. Offline Halting...
➜  microservice-1-sls-rest-api git:(main) DynamoDB Local failed to start with code 130

 Networking Error ----------------------------------------

  Error: connect ECONNREFUSED 0.0.0.0:8100
      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16)

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              12.20.1
     Framework Version:         2.57.0 (local)
     Plugin Version:            5.4.5
     SDK Version:               4.3.0
     Components Version:        3.17.1

FYIs

  • You can trigger a stream event locally here: http://localhost:3000/microservice-1/swagger.html#/Example/Create

Observations from my debugging

  • I'm using serverless-dynamodb-local which is bit of a departure from using https://github.com/mhart/dynalite, however it does support streams
  • It doesn't appear that index.end() gets called on SIGINT, I thought this was the issue
  • My theory is that the DynamodbStreamsReadable emits one last https://github.com/CoorpAcademy/serverless-plugins/blob/fb4a8a5bf1f92f38336a46d5bce8e94085aa7d4c/packages/dynamodb-streams-readable/src/index.js#L169 on closing, but I can't understand why, so I have decided to kick it off to you with this issue

cnuss avatar Oct 05 '21 22:10 cnuss