Closed pkrucz00 closed 3 weeks ago
Does your Node.js environment have the crypto
package?
require('crypto').randomUUID
This is used via uuid.v4
for generating random idempotency tokens.
Hi thank you for responding fast!
My node.js
environment has the crypto
package. A simple test on top of the script proved it's correct:
try {
require('crypto');
} catch {
console.log("crypto not found, exiting...");
process.exit(1);
}
const crypto = require('crypto');
const { randomUUID } = crypto;
console.log(randomUUID());
This logged:
4bd5df87-42db-4c84-a035-9319ba8d5476
and did not exit with 1. So it looks like the environment is ok. Do you have more questions that could solve the issue?
Hi @pkrucz00 - thanks for reaching out and your patience here.
I think we could use some more detailed steps on reproducing the error. Correct me if I'm wrong but it seems like you're using Jest to test and as I did more digging, this may be more of Jest related rather than SDK. Some of the suggestions I've found are:
Those are just my assumptions and if you could share step-by-step to reproduce, I'd attempt to replicate it on my end.
Hope it helps, John
Hi! Thank you for the research. It showed me a direction toward finding and fixing the bug. It was an error related with a jest
mock of the crypto
package. The mock was meant to resolve all the package methods as they are implemented. Probably there was a change on how do the packages load, so the mock did not work properly. The problem is gone now.
Thank you for your answers.
Regards, Pawel
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.
Checkboxes for prior research
Describe the bug
When importing the
@aws-sdk/client-s3
package:there terminal throws an error
TypeError: Cannot read properties of undefined (reading 'randomUUID')
. This makes some of tests in our application fail.SDK version number
@aws-sdk/client-s3 3.577.0
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
v20.11.0
Reproduction Steps
Observed Behavior
Expected Behavior
The client should have been imported without problems.
Possible Solution
No response
Additional Information/Context
No response