TypeError: Cannot read property 'byteLength' of undefined
See original GitHub issueI am using Kinesis with v3 nodejs.
Error TypeError: Cannot read property 'byteLength' of undefined at Object.fromArrayBuffer (/Users/mac/www/html/test-api/node_modules/@aws-sdk/util-buffer-from/dist/cjs/index.js:6:60) at Object.toBase64 [as base64Encoder] (/Users/mac/www/html/test-api/node_modules/@aws-sdk/util-base64-node/dist/cjs/index.js:23:31) at serializeAws_json1_1PutRecordsRequestEntry (/Users/mac/www/html/test-api/node_modules/@aws-sdk/client-kinesis/dist/cjs/protocols/Aws_json1_1.js:2626:80) at /Users/onebase/www/html/onebase/quoterules-api/node_modules/@aws-sdk/client-kinesis/dist/cjs/protocols/Aws_json1_1.js:2639:16 at Array.map (<anonymous>)
Code example is throwing above error is as follow : `// Import the required AWS SDK clients and commands for Node.js. const { CognitoIdentityClient } = require(“@aws-sdk/client-cognito-identity”); const { fromCognitoIdentityPool, } = require(“@aws-sdk/credential-provider-cognito-identity”); const { Kinesis, PutRecordsCommand } = require(“@aws-sdk/client-kinesis”);
// Configure Credentials to use Cognito const REGION = “us-east-2”; const client = new Kinesis({ region: REGION, credentials: fromCognitoIdentityPool({ client: new CognitoIdentityClient({ region: REGION }), identityPoolId: “MY SECRET CODE”, // IDENTITY_POOL_ID }), });
var recordData = []; // Create the Amazon Kinesis record. var record = { Data: JSON.stringify({ blog: “Wordpress”, scrollTopPercentage: “25px”, scrollBottomPercentage: “42px”, time: new Date(), }), PartitionKey: “abc”, // Must be a string. }; recordData.push(record); recordData.push(record);
console.log(“recordDatarecordData”, recordData);
const uploadData = async () => { try { const data = await client.send( new PutRecordsCommand({ Records: recordData, StreamName: “visitorDataStream”, }) ); console.log(“data”, data); console.log(“Kinesis updated”, data); } catch (err) { console.log(“Error”, err); } };
uploadData();`
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:7
Check your credentials in s3Client Try to type the credentials manual without env variables to eliminate confusion, then use the env variables
I goten same error when I used Pascal case style in AccessKeyId and SecretAccessKey:
I changed to Camel style and it works: