Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State store and/or DynamoDB client not stopped when stopConsumer() called #337

Open
GoldFlsh opened this issue May 27, 2020 · 3 comments
Open
Assignees

Comments

@GoldFlsh
Copy link

Hello, I am running into an issue where when I run my application in jest connecting to a local instance of kinesis (re: Kinesalite). However, the issue I am seeing is that it detects open handles even when stopConsumer() is called before the end of a test.

Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

I've isolated this just to when lifion-kinesis is set to consume, so I know the issue is when using this library.

My test is set up in this way ->
beforeAll(start kinesalite/dynalite) -> test(startConsumer -> stop Consumer) -> afterAll(stop kinesalite/dynalite)

When I run with https://github.com/Raynos/leaked-handles it checks what's still open and I get the following output -


no of handles 4


tcp stream {
  fd: 22,
  readable: false,
  writable: true,
  address: {},
  serverAddr: null
}

tcp stream {
  fd: 23,
  readable: false,
  writable: true,
  address: {},
  serverAddr: null
}

tcp stream {
  fd: 24,
  readable: true,
  writable: false,
  address: {},
  serverAddr: null
}

unknown handle <ref *1> Socket {
  _events: [Object: null prototype] { error: [Function: errorHandler] },
  _eventsCount: 1,
  _maxListeners: undefined,
  type: 'udp4',
  [Symbol(kCapture)]: false,
  [Symbol(asyncId)]: 722,
  [Symbol(state symbol)]: {
    handle: UDP {
      lookup: [Function: bound lookup4],
      [Symbol(owner)]: [Circular *1]
    },
    receiving: false,
    bindState: 0,
    connectState: 0,
    queue: undefined,
    reuseAddr: undefined,
    ipv6Only: undefined,
    recvBufferSize: undefined,
    sendBufferSize: undefined
  }
}

# ....after some more time ->

  console.error
    2020-05-27T13:32:43-0500 <warn> dynamodb-client.js:135 (Object.onRetry) Trying to recover from AWS.DynamoDB error…
        - Message: connect ECONNREFUSED 127.0.0.1:52005
        - Request ID: undefined
        - Code: NetworkingError (undefined)
        - Table: local-dynamodb-component-test

      at transport (../node_modules/tracer/lib/console.js:87:13)
      at ../node_modules/tracer/lib/console.js:72:3
          at Array.forEach (<anonymous>)
      at logMain (../node_modules/tracer/lib/console.js:71:19)
      at Object._self.<computed> [as warn] (../node_modules/tracer/lib/console.js:149:12)
      at Object.onRetry (../node_modules/lifion-kinesis/lib/dynamodb-client.js:135:16)
      at onError (../node_modules/async-retry/lib/index.js:33:17)
@GoldFlsh GoldFlsh changed the title State store and/or DynamoDB not stopped when stopConsumer() called State store and/or DynamoDB client not stopped when stopConsumer() called May 27, 2020
@GoldFlsh
Copy link
Author

Just to experiment I tried also adding

this.kinesis.destroy() after running stopConsumer() to see if I needed to do that and the stream handlers are still showing up as a leak even after that is completed.

The dynamodb-client retry does eventually stop if I let it sit there for a few minutes, but the leaks still don't go away at that point either. Is there anything else I need to be sure to close/destroy to make sure lifion kinesis cleans up after itself?

@eaviles
Copy link
Member

eaviles commented Jun 1, 2020

HI @GoldFlsh, thanks for reporting this. Let me take a look. I'll comment back ASAP.

@eaviles eaviles self-assigned this Jun 1, 2020
@GoldFlsh
Copy link
Author

GoldFlsh commented Jun 9, 2020

I'm actually seeing the same behavior with the kinesis-client, too now. I updated to the latest version of lifion-kinesis cause I realized I was using a slightly older version.

Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
  console.error
    2020-06-09T14:29:30-0500 <warn> kinesis-client.js:150 (Object.onRetry) Trying to recover from AWS.Kinesis error…
        - Message: connect ECONNREFUSED 127.0.0.1:64888
        - Request ID: undefined
        - Code: NetworkingError (undefined)
        - Stream: local-kinesis-component-test

....

This is after running stopConsumer() and seeing this log message.


  console.log
    2020-06-09T14:29:27-0500 <debug> lease-manager.js:268 (LeaseManager.stop) The lease manager has stopped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants