aws-sdk-js
aws-sdk-js copied to clipboard
Please remove annoying migrate to v3 warning or provide a non-invasive way to suppress it
Describe the feature
Ability to suppress the warning message:
Please migrate your code to use AWS SDK for JavaScript (v3). For more information, check the migration guide at https://a.co/7PzMCcy (Use node --trace-warnings ... to show where the warning was created) (node:48756) NOTE: The AWS SDK for JavaScript (v2) will be put into maintenance mode in 2023.
Use Case
It's incredibly annoying having this spam my console every time I run serverless.
Proposed Solution
An environment variable that can be set to hide this message.
Other Information
No response
Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
SDK version used
2
Environment details (OS name and version, etc.)
All OS
Ideally, this noisy log should be removed. It's not how deprecations are announced in the Node.js ecosystem. Simply deprecate SDK on npm instead
https://github.com/aws/aws-sdk-js/blob/c44ef6f16d51965a1e4dd10981d0cbcd7c5f9078/lib/maintenance_mode_message.js#L11-L15
Per this, the following should work:
require('aws-sdk/lib/maintenance_mode_message').suppress = true;
This should be documented somewhere more visible than the source code.
@nwalters512 this does not help when you're using a third party system like serverless and you don't have any custom JS code you can run.
This warning message is incredibly annoying and should actually be removed as pointed out by @medikoo .
I'm in agreement with you. You specifically asked for a way to suppress the warning message; one already exists.
Another reason to remove this warning entirely: the v3 SDK isn't even feature-complete (see https://github.com/aws/aws-sdk-js-v3/issues/4004), so I literally can't move to it, no matter how much I want to.
I've noticed that aws-sdk/lib/maintenance_mode_message is also not reflected in the TypeScript types, which means we have to jump through more hoops in our TypeScript project to disable this warning.
Another vote to just remove this, it is super annoying and when using it across multiple lambdas you need to suppress this over and over. For now I just patched it out with pnpm.
diff --git a/lib/maintenance_mode_message.js b/lib/maintenance_mode_message.js
index 88efd18e3ea9fb1de65642f99b451b5e553eb20c..19d02e3f276723b1a15742cb116d0da4b1955fd8 100644
--- a/lib/maintenance_mode_message.js
+++ b/lib/maintenance_mode_message.js
@@ -23,9 +23,3 @@ function emitWarning() {
});
}
}
-
-setTimeout(function () {
- if (!module.exports.suppress) {
- emitWarning();
- }
-}, 0);
Please be so kind and remove it, adopt a proper way to announce the change, and please do it only when actually ready to be implemented. Appreciate the team's efforts nonetheless 🙏
Hi people, the intention of this warning is to let you all know about our plans regarding the AWS SDK for JavaScript V2, however, I agree with all of you about that printing this warning, in every console operation we do with the SDK, is not the best experience. I will discuss about this with the team to discuss about possible alternatives.
I will get back to you people as soon as possible.
Thanks!
Thank you for looking into it! I'd be pleased as well if this warning was removed.
Serverless will suppress the message in a new version, according to this: https://github.com/serverless/serverless/pull/11769.
For other direct users of the aws-sdk package in Node.js, use the following to suppress the message:
require('aws-sdk/lib/maintenance_mode_message').suppress = true;
I will see if we can add an environment variable for suppression as well.
https://github.com/aws/aws-sdk-js/pull/4357
Thanks @kuhe.
@yenfryherrerafeliz the message itself isn't the problem, it's not just saying you have 'plans', it's instructing the developer to do something that's unfeasible. V3 is not ready to move to yet otherwise we'd all have heeded the warning. It's was a premature move, and I'm STILL waiting on https://github.com/aws/aws-sdk-js-v3/issues/4004 which was raised last September.
In the next release (expected later today), there will be 3 ways to suppress this message.
in https://github.com/aws/aws-sdk-js/blob/master/lib/maintenance_mode_message.js
- JS code for suppression
require('aws-sdk/lib/maintenance_mode_message').suppress = true;
- detection of the AWS Lambda environment (via env
AWS_EXECUTION_ENV=AWS_Lambda_...) - detection of a specific env var
AWS_SDK_JS_SUPPRESS_MAINTENANCE_MODE_MESSAGE=1
Serverless users- make sure to use serverless ^3.28.1 https://github.com/serverless/serverless/releases/tag/v3.28.1
I still get the warning after updating to serverless 3.28.1
Hello everyone, I have encountered the same error. Is it necessary to migrate to v3?? Thanks for your help
The v3 is still in preview . From https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/preview/, it says "This AWS SDK API Reference for JavaScript v3 is in preview" . Am I missing something? Why are we getting this warning asking us to move to a beta library ?
edit: this comment is wrong. Apparently, it is the docs that are in preview and not the library itself.
@gramakri This is a preview of the new API reference, as opposed to the old API reference. aws-sdk-js-v3 has been generally available since 2020.
@cj-christoph-gysin Thanks for the clarification!
` "@aws-sdk/client-ec2": "^3.353.0",
"@aws-sdk/client-s3": "^3.353.0",
"@aws-sdk/client-secrets-manager": "3.353.0",
"@aws-sdk/lib-storage": "^3.353.0",
"@aws-sdk/node-http-handler": "^3.350.0",
"@aws-sdk/s3-request-presigner": "^3.353.0",
"@aws-sdk/types": "^3.347.0",`
I am using these modules, latest and upgraded but still getting that warning message while starting the server, any specific reason?
@NanditShah does setting an ENV AWS_SDK_JS_SUPPRESS_MAINTENANCE_MODE_MESSAGE=1 work for you?
I put ENV AWS_SDK_JS_SUPPRESS_MAINTENANCE_MODE_MESSAGE=1 on all my API & SQS lambdas but it still doesn't suppress the error message.
ERROR (node:8) NOTE: We are formalizing our plans to enter AWS SDK for JavaScript (v2) into maintenance mode in 2023.
Please migrate your code to use AWS SDK for JavaScript (v3).
For more information, check the migration guide at https://a.co/7PzMCcy
(Use `node --trace-warnings ...` to show where the warning was created)
AWS_SDK_JS_SUPPRESS_MAINTENANCE_MODE_MESSAGE=1 only worked for me in CLI mode, at least calling jest now suppress the message:
package.json
"test": "AWS_SDK_JS_SUPPRESS_MAINTENANCE_MODE_MESSAGE=1 jest --maxWorkers=50% --silent",
I am on node v14.19.3 (I know ...) I just "npm install aws-sdk" for a new project I am starting on.
And I get this warning. Why is the default install of this package deprecated?
$ grep aws-sdk package.json
"aws-sdk": "^2.1450.0",
$ grep version node_modules/aws-sdk/package.json
"version": "2.1450.0"
Another reason to remove this warning entirely: the v3 SDK isn't even feature-complete (see aws/aws-sdk-js-v3#4004), so I literally can't move to it, no matter how much I want to.
further, dynamodb-local doesn't work with v3.
Hello, we will be initiating end of support for JS v2 this September. Since we've added a way to suppress this warning in v2, I will be closing this issue.