-
Notifications
You must be signed in to change notification settings - Fork 597
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
Next.JS 14.2.23 - Importing @aws-sdk/crc64-nvme-crt" as required but fails to fetch S3 objects. #6822
Comments
This issue happens as the S3 objects were uploaded with CRC64NVME checksums - either by another JS SDK application which had the required additional The S3 backend returns the CRC64NVME checksum, and the JS SDK fails since the optional dependency is not available. |
We're discussing internally on how the behavior should be. Ideally, the JS SDK should skip validating the checksum for get operations if the dependency is not available. It's because the application did not explicitly request checksum to be validate using CRC64-NVME algorithm. The fix is likely to be released on Tuesday Jan 21st or Wednesday Jan 22nd. For a quick fix, you can pin the SDK version to |
I found out the following: The project is in a monorepo structure in the following way: The two packages, nextjsapp and lambda use @aws-sdk/client-s3 library. For the NextJS app, the version in package.json was: "@aws-sdk/client-s3": "^3.705.0" Now, at the moment of installing the packages, the package installed was "@aws-sdk/client-s3": "3.730.0". Which means that's the version that is used in both packages. This leads me to the error described above. After I forced setting the package version to
in both packages of the monorepo, deleting the packages ( and reinstalling packages That forces to install the version "@aws-sdk/client-s3": "3.705.0". At version 3.705.0, I didn't see any errors |
That makes sense, as my solution was to use version |
After the fix is released, will it still require installing and importing Could it just come as a dependency of the |
We're still discussing internally. As explained in #6822 (comment) I don't think we'll require dependency to be explicitly installed.
|
No. The AWS SDK for JavaScript customers are sensitive to install sizes, and the |
Minimal repro PutObjectThis can be another JS SDK application which has optional dependency, or another AWS SDK which includes CRC64NVME checksum by default. Running this file will register CRC64NVME checksum with S3 backend. // putObject.mjs
import { S3, ChecksumAlgorithm } from "@aws-sdk/client-s3"; // >=v3.729.0
import "@aws-sdk/crc64-nvme-crt";
const client = new S3();
const Bucket = "test-flexible-checksums-v2"; // Change to your bucket name.
const Key = "foo";
const Body = "bar";
await client.putObject({ Bucket, Key, Body, ChecksumAlgorithm: ChecksumAlgorithm.CRC64NVME }); GetObjectThis is a JS SDK application which performs data integrity checks by default. // putObject.mjs
import { S3 } from "@aws-sdk/client-s3"; // >=v3.729.0
const client = new S3();
const Bucket = "test-flexible-checksums-v2";
const Key = "foo";
// ChecksumMode not required to be set in >=v3.729.0
await client.getObject({ Bucket, Key, ChecksumMode: "ENABLED" }); This throws error in /Users/trivikr/workspace/test/node_modules/@aws-sdk/middleware-flexible-checksums/dist-cjs/index.js:209
throw new Error(
^
Error: Please check whether you have installed the "@aws-sdk/crc64-nvme-crt" package explicitly.
You must also register the package by calling [require("@aws-sdk/crc64-nvme-crt");] or an ESM equivalent such as [import "@aws-sdk/crc64-nvme-crt";].
For more information please go to https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt
at selectChecksumAlgorithmFunction (/Users/trivikr/workspace/test/node_modules/@aws-sdk/middleware-flexible-checksums/dist-cjs/index.js:209:15)
at validateChecksumFromResponse (/Users/trivikr/workspace/test/node_modules/@aws-sdk/middleware-flexible-checksums/dist-cjs/index.js:411:35)
at /Users/trivikr/workspace/test/node_modules/@aws-sdk/middleware-flexible-checksums/dist-cjs/index.js:466:11
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async /Users/trivikr/workspace/test/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:174:20
at async /Users/trivikr/workspace/test/node_modules/@smithy/middleware-serde/dist-cjs/index.js:33:24
at async /Users/trivikr/workspace/test/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:483:18
at async /Users/trivikr/workspace/test/node_modules/@smithy/middleware-retry/dist-cjs/index.js:321:38
at async /Users/trivikr/workspace/test/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:109:22
at async /Users/trivikr/workspace/test/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:136:14 {
'$metadata': { attempts: 1, totalRetryDelay: 0 }
}
Node.js v22.13.0 Verified that error is not thrown in |
Code workarounds if you can't pin your SDK dependency to Recommended: Manually install
|
This issue is now closed. Comments on closed issues are hard for our team to see. |
The quick fix in #6835 will be published with https://github.com/aws/aws-sdk-js-v3/releases/tag/v3.732.0 around 12:00 PM Pacific today (Tue Jan 21) We're discussing a long-term fix, especially on what the warnings should be. |
Verified that this issue is fixed in https://github.com/aws/aws-sdk-js-v3/releases/tag/v3.732.0, and workarounds are not needed PutObjectThis can be another JS SDK application which has optional dependency, or another AWS SDK which includes CRC64NVME checksum by default. Running this file will register CRC64NVME checksum with S3 backend. // putObject.mjs
import { S3, ChecksumAlgorithm } from "@aws-sdk/client-s3"; // >=v3.732.0
import "@aws-sdk/crc64-nvme-crt";
const client = new S3();
const Bucket = "test-flexible-checksums-v2"; // Change to your bucket name.
const Key = "foo";
const Body = "bar";
await client.putObject({ Bucket, Key, Body, ChecksumAlgorithm: ChecksumAlgorithm.CRC64NVME }); GetObjectThis is a JS SDK application which performs data integrity checks by default. // getObject.mjs
import { S3 } from "@aws-sdk/client-s3"; // >=v3.732.0
const client = new S3();
const Bucket = "test-flexible-checksums-v2";
const Key = "foo";
await client.getObject({ Bucket, Key }); |
Update S3 client to remove checksum error See aws/aws-sdk-js-v3#6822 (comment)
Update S3 client to remove checksum error See aws/aws-sdk-js-v3#6822 (comment)
We just now encountered this as a runtime error in an application that reads from S3. There is a separate external application that was rebuilt and picked up the latest AWS SDK version. This external application puts data into S3. I am guessing that when it placed new data into S3, the integrity checksums were added. It suddenly breaks the original application that reads from S3, just because the original application was unlucky enough to have been built with the Can we at least mark in npmjs that those range of versions are broken? At least the application will fail to rebuild and would force the developers to reference a later fixed version. |
Hey @peter-at-work , Sorry for this experience. Version
|
Thank you for this information. I wonder if AWS should also deprecate the relevant versions of the higher-level package If the deprecation warning message appears on the This is also a side-effect of the AWS SDK clients using exact version references for some of the transitive dependencies, instead of semver caret I'm pretty sure there are valid reasons for AWS to use exact version references to transitive dependencies instead of caret |
Checkboxes for prior research
Describe the bug
I have a project in Next.JS 14.2.23 facing the following error using NodeJS v20.10.0
This error occurs when I trigger the
getFileStreamFromS3
function, which is a straightforward function that fetches an object from s3According to the error message, I need to install and import
@aws-sdk/crc64-nvme-crt
, which I didHowever, the error keeps showing up.
Here are the package versions I'm using:
Regression Issue
SDK version number
@aws-sdk/[email protected], @aws-sdk/crc64-nvme-crt": "^3.730.0
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
v20.10.0
Reproduction Steps
Trigger the following function
And it fails after triggering
Observed Behavior
Here is the error thrown
Expected Behavior
I expected to fetch the file/object from S3
Possible Solution
No response
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered: