Closed rajashril closed 2 years ago
The environment info you shared shows that you have @aws-amplify/core
and @aws-amplify/pushnotification
as well as aws-amplify
. This means that you likely have duplicate, conflicting versions of these dependencies installed. See https://docs.amplify.aws/lib/troubleshooting/upgrading/q/platform/js for more info.
Please try the following steps:
npm uninstall @aws-amplify/pushnotification @aws-amplify/core
rm -rf node_modules package-lock.json
npm i
npx pod-install
When I followed the steps mentioned above, still I am getting the same error and some new errors get introduced due to this. Attaching screen shots for the same.
I have followed the steps mention here https://docs.amplify.aws/lib/push-notifications/getting-started/q/platform/js#requirements for push notification setup, so I think @aws-amplify/pushnotification
needed.
Hi @rajashril
I was tracking the code that causes the Cannot read property 'byteLength' of undefined
and looks like the problem is that there are no credentials available to the sigv4 signer, I've seen this happen when there are multiple/conflicting versions of Amplify packages in the project
In addition to what @iartemiev suggested, can you make sure that you no longer have duplicate versions of packages by following the instructions here: https://docs.amplify.aws/lib/troubleshooting/upgrading/q/platform/js ?
Hi,
I have followed the steps mention here https://docs.amplify.aws/lib/troubleshooting/upgrading/q/platform/js#check-for-duplicate-versions to check for any duplicate version but it does not return any thing, that means I do not have any duplicate version of amplify packages in my project.
When I followed the steps mentioned above, still I am getting the same error and some new errors get introduced due to this. Attaching screen shots for the same.
@rajashril Could you share your usage of Amplify in your application?
Hi, We are using amplify to store the endpoints in pinpoint. I already shared the environment details with you. I have had screen share session with aws support team(both pinpoint and amplify team) and after verifying configs they concluded that seems like this is the issue with amplify sdk (sdk is not able to send information correctly to pinpoint so it missing). There are two issues
Bumping this. I'm having the same issue:
[Error] Failed to load resource: the server responded with a status of 400 () (cognito-identity.us-east-1.amazonaws.com, line 0) [Error] Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'data.byteLength') step (0.chunk.js:461163) (anonymous function) (0.chunk.js:461059) Promise awaiter (0.chunk.js:461038) (anonymous function) (0.chunk.js:277974) step (0.chunk.js:461155) fulfilled (0.chunk.js:461041) promiseReactionJob [Error] [ERROR] 02:24.341 AWSPinpointProvider - updateEndpoint failed TypeError: undefined is not an object (evaluating 'data.byteLength') isEmptyData — isEmptyData.ts:8 (anonymous function) — webCryptoSha256.ts:33 (anonymous function) — crossPlatformSha256.ts:23 hmac — credentialDerivation.ts:69 (anonymous function) — credentialDerivation.ts:39 step — tslib.es6.js:100 (anonymous function) — tslib.es6.js:74 Promise awaiter — tslib.es6.js:70 (anonymous function) — SignatureV4.ts:237 step — tslib.es6.js:100 fulfilled — tslib.es6.js:71 promiseReactionJob (anonymous function) (anonymous function) (0.chunk.js:15873) (anonymous function) (0.chunk.js:15966) (anonymous function) (0.chunk.js:1968) step (0.chunk.js:1435) (anonymous function) (0.chunk.js:1338) Promise (anonymous function) (0.chunk.js:1317) (anonymous function) (0.chunk.js:1935) step (0.chunk.js:1435) rejected (0.chunk.js:1328) promiseReactionJob
Hi, We are using amplify to store the endpoints in pinpoint. I already shared the environment details with you. I have had screen share session with aws support team(both pinpoint and amplify team) and after verifying configs they concluded that seems like this is the issue with amplify sdk (sdk is not able to send information correctly to pinpoint so it missing). There are two issues
- Sometimes endpoints are not getting created in pinpoint but we are receiving endpoint id in callback function
- Sometimes endpoints are getting created in pinpoint but without address field so it is useless for us as we use endpoints to send push notification to the customer and without address pinpoint is not be able to send those. NOTE : Both of these are intermittent.
Any updates on this?
Bumping as also having same issue after upgrading from 2.2.5 to 4.2.1
I have also run the deduplication check which returned
yarn list --pattern amplify |
Select-String -Pattern '(@?aws-amplify[^@]).(?<!deduped)$' | %{$.Matches.Groups[1].value} | Group-Object | Where-Object { $.Count -gt 1 } | Select-Object -ExpandProperty Name | Sort-Object @aws-amplify/core
also ran yarn upgrade --latest --pattern aws-amplify then rebuilt the apk and still get same issue when we call updateEndpoint. All the AuthStore variables are valid and populated and we NEVER reach the log line after the update.
await Analytics.updateEndpoint({
address: AuthStore.deviceId,
optOut: 'NONE',
userId: AuthStore.username
});
console.log('PushStore: updatePinpoint: completed');
Having the same issue - "aws-amplify": "^4.2.2"
Amplify.configure({
Auth: {
region: 'us-east-1',
identityPoolRegion: 'us-east-1',
identityPoolId: 'XXXXXXX',
userPoolId: 'XXXXXXXX',
userPoolWebClientId: 'XXXXXXXXX',
},
Analytics: {
AWSPinpoint: {
region: 'us-east-1',
appId: 'XXXXXXX',
},
},
});
Analytics.autoTrack('session', { enable: true });
Analytics.autoTrack('pageView', { enable: true, type: 'SPA' });
Analytics.autoTrack('event', {
enable: true,
events: ['click'],
selectorPrefix: 'data-analytics-',
});
Whats the hold up on this getting some traction?
We need to upgrade Amplify due to AWS request yet the lastest versions are causing havoc such as this
Having the same issue - "aws-amplify": "^4.2.5"
any update?
Having the same issue -
"aws-amplify": "^4.2.2"
Amplify.configure({ Auth: { region: 'us-east-1', identityPoolRegion: 'us-east-1', identityPoolId: 'XXXXXXX', userPoolId: 'XXXXXXXX', userPoolWebClientId: 'XXXXXXXXX', }, Analytics: { AWSPinpoint: { region: 'us-east-1', appId: 'XXXXXXX', }, }, }); Analytics.autoTrack('session', { enable: true }); Analytics.autoTrack('pageView', { enable: true, type: 'SPA' }); Analytics.autoTrack('event', { enable: true, events: ['click'], selectorPrefix: 'data-analytics-', });
Adding mandatorySignIn
to Auth
fixing issue for me
Amplify.configure({
Auth: {
mandatorySignIn: true
}
});
Tried the mandatory SignIn flag. makes it even worse in that it appears to kill of AppSync from working with an error indicating its not happy about region and appId etc
What I can get working is basic helloWord app that guns up Analytics and App OK
import Amplify, {Analytics} from 'aws-amplify';
import PushNotification from '@aws-amplify/pushnotification';
import awsConfig from './src/config/aws';
const options = {
Auth: awsConfig.Auth,
Analytics: awsConfig.AWSPinpoint,
PushNotification: awsConfig.PushNotification,
API: awsConfig.API,
};
Amplify.configure(options);
PushNotification.onRegister(token => {
console.log('in app registration', token);
});
Analytics.updateEndpoint({
address: 'xxx',
optOut: 'NONE',
userId: 'xxx',
});
AppRegistry.registerComponent(appName, () => App);
awsConfig.AWSPinpoint is
{"disabled":false,"autoSessionRecord":true,"AWSPinpoint":{"appId":"_REDACTED_","region":"ap-southeast-2","mandatorySignIn":true}}
Its when I point App to my actual application source that it all goes awry (of course)
Even when I comment out any code relating to .updateEndpoint I still see sometimes up to 3 errors
ERROR [ERROR] 42:13.170 AWSPinpointProvider - updateEndpoint failed [TypeError: undefined is not an object (evaluating 'data.byteLength')]
ERROR [ERROR] 42:13.214 AWSPinpointProvider - updateEndpoint failed [TypeError: undefined is not an object (evaluating 'data.byteLength')]
ERROR [ERROR] 42:13.243 AWSPinpointProvider - updateEndpoint failed [TypeError: undefined is not an object (evaluating 'data.byteLength')]
WARN Possible Unhandled Promise Rejection (id: 0):
TypeError: undefined is not an object (evaluating 'data.byteLength')
I cant only take so much out of app before its unusable but safe to say I have commented any use (and there was only one), where Analytics.updateEndpoint is called after the user signs in, and we wish to start to use Analytics and enable autotracking with some custom metadata and update the PN endpoint with some metadata also
Where we use Amplify deeper in the App its pretty standard stuff Id say ie
import Auth, {Analytics} from 'aws-amplify';
console.log('postSignIn: starting mobile analytics')
Analytics.autoTrack('session', {
enable: true,
attributes: {
sub: username
},
provider: 'AWSPinpoint'
});
Anyone got any ideas on where next? I'm very much stuck
I should also add the adding await to .updateEndpoint seemed to cause issues as well so I've removed
If I try await Analytics.updateEndpoint(...) then app completely crashes with
Unexpected identifier '_awsAmplify'
Unexpected identifier '_awsAmplify'
no stack
no stack
Have traced the issue
Eventually tracked down to a package 'fast-text-encoding' which is required by Joi
it breaks Analytics as per previous updates
Replacing with "text-encoding-polyfill" resolves the issue and also resolves the await issue
Hi @rajashril 👋 are you still experiencing this issue and in need of assistance?
Closing this issue since we dont have much activity in here. Hope @markl-vesper suggestion works. If this is still an issue, please reach out and I will re-open this issue.
@ashika01 Yes, this is still an issue. I'm getting the same error when trying to updateEndpoint
with all suggestions and fixes from this thread.
did u try the suggestion above?
Im having the same issue on my nextjs project
import { Analytics } from '@aws-amplify/analytics';
const analyticsConfig = {
Auth: {
region: config.AWS_REGION,
identityPoolId: config.COGNITO_IDENTITY_POOL_ID,
userPoolId: config.COGNITO_USER_POOL_ID,
userPoolWebClientId: config.COGNITO_USER_POOL_CLIENT_ID
},
AWSPinpoint: {
appId: 'APP_ID',
region: 'ap-northeast-1',
},
}
Analytics.configure(analyticsConfig)
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server amplify-help
forum.
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Analytics, Push Notifications
Amplify Categories
analytics, notifications
Environment information
Describe the bug
Endpoints are not getting updated in aws pinpoints and getting error
AWSPinpointProvider - updateEndpoint failed TypeError: Cannot read property 'byteLength' of undefined
.Expected behavior
Endpoints should get updated in aws pinpoints
Reproduction steps
Please check attached screenshot
Code Snippet
Log output
aws-exports.js
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response