Skip to content

Commit

Permalink
Skip emitting maintenance mode message on Lambda (#4365)
Browse files Browse the repository at this point in the history
* Skip emitting maintenance mode message on Lambda

* Move typeof process check at the top

* Change to indexOf

* npm run add-change

* update category

* check for process being undefined
  • Loading branch information
trivikr authored Mar 10, 2023
1 parent 3c65b8b commit 07a07b3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "maintenance mode message",
"description": "supress maintenance mode message in Lambda environment"
}
13 changes: 11 additions & 2 deletions lib/maintenance_mode_message.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,19 @@ module.exports = {
* require('aws-sdk/lib/maintenance_mode_message').suppress = true;
*/
function emitWarning() {
if (typeof process === 'undefined')
return;

// Skip maintenance mode message in Lambda environments
if (
typeof process !== 'undefined' &&
typeof process.emitWarning === 'function'
typeof process.env === 'object' &&
typeof process.env.AWS_EXECUTION_ENV !== 'undefined' &&
process.env.AWS_EXECUTION_ENV.indexOf('AWS_Lambda_') === 0
) {
return;
}

if (typeof process.emitWarning === 'function') {
process.emitWarning(warning, {
type: 'NOTE'
});
Expand Down

0 comments on commit 07a07b3

Please sign in to comment.