Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@middy/do-not-wait-for-empty-event-loop
Advanced tools
Middleware for the middy framework that allows to easily disable the wait for empty event loop in a Lambda function
"Do not wait for empty event loop" middleware for the middy framework, the stylish Node.js middleware engine for AWS Lambda
This middleware sets context.callbackWaitsForEmptyEventLoop
property to false
.
This will prevent Lambda from timing out because of open database connections, etc.
To install this middleware you can use NPM:
npm install --save @middy/do-not-wait-for-empty-event-loop
By default the middleware sets the callbackWaitsForEmptyEventLoop
property to false
only in the before
phase,
meaning you can override it in handler to true
if needed. You can set it in all steps with the options:
runOnBefore
(defaults to true
) - sets property before running your handlerrunOnAfter
(defaults to false
)runOnError
(defaults to false
)const middy = require('@middy/core')
const doNotWaitForEmptyEventLoop = require('@middy/do-not-wait-for-empty-event-loop')
const handler = middy((event, context, cb) => {
cb(null, {})
})
handler.use(doNotWaitForEmptyEventLoop({runOnError: true}))
// When Lambda runs the handler it gets context with callbackWaitsForEmptyEventLoop property set to false
handler(event, context, (_, response) => {
expect(context.callbackWaitsForEmptyEventLoop).toEqual(false)
})
For more documentation and examples, refers to the main Middy monorepo on GitHub or Middy official website.
Everyone is very welcome to contribute to this repository. Feel free to raise issues or to submit Pull Requests.
Licensed under MIT License. Copyright (c) 2017-2018 Luciano Mammino and the Middy team.
FAQs
Middleware for the middy framework that allows to easily disable the wait for empty event loop in a Lambda function
The npm package @middy/do-not-wait-for-empty-event-loop receives a total of 0 weekly downloads. As such, @middy/do-not-wait-for-empty-event-loop popularity was classified as not popular.
We found that @middy/do-not-wait-for-empty-event-loop demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.