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

Dynalite takes a long time to close (5 seconds) #181

Open
reconbot opened this issue Sep 8, 2023 · 1 comment
Open

Dynalite takes a long time to close (5 seconds) #181

reconbot opened this issue Sep 8, 2023 · 1 comment

Comments

@reconbot
Copy link
Member

reconbot commented Sep 8, 2023

Describe the issue
When using dynalite for testing I open a new dynalite for each test case and create new in memory tables.

async function startserver() {
  const server = createServer({ createTableMs: 0, deleteTableMs: 0, updateTableMs: 0 })
  const port = await getPortPromise() // `port-finder` is magic btw
  await new Promise((resolve) => server.listen(port, resolve))
  return server
}

And then close it after each test case

async function stopServer(server) {
   await new Promise((resolve, reject) => server.close(err => err ? reject(err) : resolve()))
}

However the close takes forever! So I often skip it and pray. But why does it take forever? I believe the AWS-SDK keeps the connection open. Since it's an http server you can actually close all connections which reduces the time to close to mere milliseconds.

async function stopServer(server) {
   const closePromise = new Promise((resolve, reject) => server.close(err => err ? reject(err) : resolve()))
   server.closeAllConnections()
   await closePromise
}

This isn't so much a bug as something people will run into so I wanted to document it.

@ryanblock
Copy link
Member

ryanblock commented Sep 8, 2023

Yeah, not a bug with this library, it’s an issue with how AWS folks changed the Node keepalive logic between v2 and v3. See: architect/functions@f80010f

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