aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.4k stars 2.11k forks source link

Endpoints are not getting updated in aws pinpoints and getting error - AWSPinpointProvider - updateEndpoint failed TypeError: Cannot read property 'byteLength' of undefined. #8385

Closed rajashril closed 2 years ago

rajashril commented 3 years ago

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Analytics, Push Notifications

Amplify Categories

analytics, notifications

Environment information

``` System: OS: macOS 10.15.7 CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz Memory: 96.22 MB / 16.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 14.10.0 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 6.14.8 - /usr/local/bin/npm Browsers: Chrome: 84.0.4147.135 Safari: 13.1.3 npmPackages: @aws-amplify/core: ^4.0.3 => 4.0.3 @aws-amplify/pushnotification: ^4.0.3 => 4.0.3 @babel/core: ^7.11.0 => 7.13.15 @babel/runtime: ^7.11.0 => 7.12.5 (7.14.0) @react-native-async-storage/async-storage: ^1.15.4 => 1.15.4 @react-native-community/clipboard: ^1.2.3 => 1.5.1 @react-native-community/datetimepicker: ^3.4.7 => 3.4.7 @react-native-community/eslint-config: ^2.0.0 => 2.0.0 @react-native-community/masked-view: ^0.1.10 => 0.1.10 @react-native-community/netinfo: ^5.9.7 => 5.9.10 @react-native-community/push-notification-ios: ^1.8.0 => 1.8.0 (1.0.3) @react-native-firebase/analytics: ^7.6.4 => 7.6.10 @react-native-firebase/app: ^8.4.3 => 8.4.7 @react-native-firebase/crashlytics: ^8.4.5 => 8.5.2 @react-native-picker/picker: ^1.9.8 => 1.9.10 @react-navigation/bottom-tabs: ^5.8.0 => 5.11.7 @react-navigation/native: ^5.7.3 => 5.9.2 @react-navigation/stack: ^5.9.0 => 5.14.2 HelloWorld: 0.0.1 aws-amplify: ^4.0.3 => 4.0.3 axios: ^0.21.1 => 0.21.1 babel-jest: ^26.2.2 => 26.6.3 email-validator: ^2.0.4 => 2.0.4 eslint: ^7.6.0 => 7.18.0 hermes-inspector-msggen: 1.0.0 jest: ^26.2.2 => 26.6.3 jetifier: ^2.0.0 => 2.0.0 (1.6.6) libphonenumber-js: ^1.7.56 => 1.9.9 libphonenumber-js-core: 1.0.0 libphonenumber-js-max: 1.0.0 libphonenumber-js-min: 1.0.0 libphonenumber-js-mobile: 1.0.0 lottie-ios: 3.1.8 => 3.1.8 lottie-react-native: ^3.5.0 => 3.5.0 metro-react-native-babel-preset: ^0.61.0 => 0.61.0 (0.59.0) millify: ^3.3.0 => 3.5.0 password-validator: ^5.1.0 => 5.1.1 qs: ^6.9.4 => 6.9.6 (6.5.2) react: 16.13.1 => 16.13.1 react-animated: 0.1.0 react-native: 0.63.2 => 0.63.2 react-native-android-open-settings: 1.3.0 => 1.3.0 react-native-code-push: ^6.3.0 => 6.4.1 react-native-flipper: ^0.61.0 => 0.61.0 (0.37.0) react-native-gesture-handler: ^1.7.0 => 1.9.0 react-native-image-crop-picker: ^0.33.2 => 0.33.4 react-native-inset-shadow: ^1.0.3 => 1.0.3 react-native-linear-gradient: ^2.5.6 => 2.5.6 react-native-loading-spinner-overlay: ^1.1.0 => 1.1.0 react-native-localize: ^1.4.2 => 1.4.3 react-native-modal: ^11.5.6 => 11.6.1 react-native-modal-datetime-picker: 9.2.0 => 9.2.0 react-native-modal-selector: ^2.0.3 => 2.0.3 react-native-number-ticker: ^0.1.5 => 0.1.5 react-native-offline: ^5.7.0 => 5.7.0 react-native-otp-textinput: 0.0.8 => 0.0.8 react-native-permissions: 3.0.0 => 3.0.0 react-native-picker-select: ^8.0.4 => 8.0.4 react-native-reanimated: ^1.10.1 => 1.13.2 react-native-responsive-screen: ^1.4.1 => 1.4.2 react-native-safe-area-context: ^3.1.4 => 3.1.9 react-native-screens: ^2.9.0 => 2.17.1 react-native-splash-screen: ^3.2.0 => 3.2.0 react-native-swiper: ^1.6.0 => 1.6.0 react-native-ticker: ^4.0.0 => 4.0.0 react-native-toast-message: ^1.4.9 => 1.4.9 react-native-user-avatar: ^1.0.7 => 1.0.7 react-native-vector-icons: ^7.0.0 => 7.1.0 react-native-version-check: ^3.4.1 => 3.4.2 react-redux: ^7.2.1 => 7.2.2 react-test-renderer: 16.13.1 => 16.13.1 redux: ^4.0.5 => 4.0.5 redux-flipper: ^1.3.1 => 1.4.2 redux-logger: ^3.0.6 => 3.0.6 redux-saga: ^1.1.3 => 1.1.3 redux-saga/effects: undefined () responsive-screen: 0.1.0 responsive-screen-orientation-change: 0.1.0 responsive-screen-styled-components: 0.1.0 rn-async-storage-flipper: ^0.0.9 => 0.0.9 rn-nodeify: ^10.3.0 => 10.3.0 npmGlobalPackages: @aws-amplify/cli: 4.51.2 appcenter-cli: 2.7.3 appium-doctor: 1.16.0 appium: 1.20.2 code-push-cli: 3.0.0 expo-cli: 3.28.5 grunt-cli: 1.3.2 gulp-cli: 2.3.0 ios-deploy: 1.11.4 n: 7.0.0 npm: 6.14.8 react-native-cli: 2.0.1 ```

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

Screenshot 2021-06-03 at 5 55 09 PM

Please check attached screenshot

Code Snippet

// Put your code below this line.

Log output

``` [DEBUG] 39:30.825 Amplify - amplify config {aws_project_region: "us-east-1", aws_cognito_identity_pool_id: "us-east-1:xxxxx", aws_cognito_region: "us-east-1", oauth: {…}, aws_mobile_analytics_app_id: "xxxx", …} ConsoleLogger.js:97 [DEBUG] 39:30.856 I18n - configure I18n ConsoleLogger.js:97 [DEBUG] 39:30.858 I18n - create I18n instance ConsoleLogger.js:97 [DEBUG] 39:30.859 AuthClass - configure Auth ConsoleLogger.js:107 [DEBUG] 39:30.861 Parser - parse config (3) [{…}, "to amplifyconfig", {…}] ConsoleLogger.js:107 [DEBUG] 39:30.876 Hub - Dispatching to auth with {event: "configured", data: null, message: "The Auth category has been configured successfully"} ConsoleLogger.js:107 [DEBUG] 39:30.890 Hub - Dispatching to auth with {event: "configured", data: null, message: "The Auth category has been configured successfully"} ConsoleLogger.js:107 [DEBUG] 39:30.892 AnalyticsClass - on hub capsule auth {event: "configured", data: null, message: "The Auth category has been configured successfully"} ConsoleLogger.js:107 [DEBUG] 39:30.894 AnalyticsClass - configure Analytics {aws_project_region: "us-east-1", aws_cognito_identity_pool_id: "us-east-1:xxxx", aws_cognito_region: "us-east-1", oauth: {…}, aws_mobile_analytics_app_id: "xxxxxxx", …} ConsoleLogger.js:107 [DEBUG] 39:30.907 Parser - parse config (3) [{…}, "to amplifyconfig", {…}] ConsoleLogger.js:107 [DEBUG] 39:30.909 AWSPinpointProvider - configure Analytics {disabled: undefined, autoSessionRecord: true, appId: "xxxxx", region: "us-east-1"} ConsoleLogger.js:97 [DEBUG] 39:30.925 AsyncStorageCache - Get item: key is AWSPinpoint_xxxxxxxx with options undefined ConsoleLogger.js:107 [DEBUG] 39:30.944 Hub - Dispatching to analytics with {event: "configured", data: null, message: "The Analytics category has been configured successfully"} ConsoleLogger.js:107 [DEBUG] 39:30.975 AnalyticsClass - on hub capsule analytics {event: "configured", data: null, message: "The Analytics category has been configured successfully"} ConsoleLogger.js:107 [DEBUG] 39:31.7 AnalyticsClass - current configuration {autoSessionRecord: true, AWSPinpoint: {…}, aws_project_region: "us-east-1", aws_cognito_identity_pool_id: "us-east-1:xxxx", aws_cognito_region: "us-east-1", …} ConsoleLogger.js:97 [DEBUG] 39:31.11 Storage - storage configure called ConsoleLogger.js:97 [DEBUG] 39:31.26 StorageClass - configure Storage ConsoleLogger.js:107 [DEBUG] 39:31.43 Parser - parse config (3) [{…}, "to amplifyconfig", {…}] ConsoleLogger.js:107 [DEBUG] 39:31.79 AWSS3Provider - configure Storage undefined ConsoleLogger.js:97 [DEBUG] 39:31.91 Storage - storage vault configure called ConsoleLogger.js:97 [DEBUG] 39:31.92 StorageClass - configure Storage ConsoleLogger.js:107 [DEBUG] 39:31.94 Parser - parse config (3) [{…}, "to amplifyconfig", {…}] ConsoleLogger.js:107 [DEBUG] 39:31.107 AWSS3Provider - configure Storage undefined ConsoleLogger.js:107 [DEBUG] 39:31.108 RestAPI - configure Rest API {opt: {…}} ConsoleLogger.js:97 [DEBUG] 39:31.109 RestAPI - create Rest API instance ConsoleLogger.js:107 [DEBUG] 39:31.110 RestClient - API Options {endpoints: Array(0), aws_project_region: "us-east-1", aws_cognito_identity_pool_id: "us-east-1:xxxx", aws_cognito_region: "us-east-1", oauth: {…}, …} ConsoleLogger.js:107 [DEBUG] 39:31.112 PubSub - configure PubSub {opt: {…}} ConsoleLogger.js:107 [DEBUG] 39:31.124 GraphQLAPI - configure GraphQL API {opt: {…}} ConsoleLogger.js:97 [DEBUG] 39:31.125 GraphQLAPI - create Rest instance ConsoleLogger.js:107 [DEBUG] 39:31.126 RestClient - API Options {aws_project_region: "us-east-1", aws_cognito_identity_pool_id: "us-east-1:xxxx", aws_cognito_region: "us-east-1", oauth: {…}, aws_mobile_analytics_app_id: "xxxxxx", …} ConsoleLogger.js:107 [DEBUG] 39:31.128 RestAPI - configure Rest API {opt: {…}} ConsoleLogger.js:97 [DEBUG] 39:31.140 RestAPI - create Rest API instance ConsoleLogger.js:107 [DEBUG] 39:31.141 RestClient - API Options {endpoints: Array(0), aws_project_region: "us-east-1", aws_cognito_identity_pool_id: "us-east-1:xxxxx", aws_cognito_region: "us-east-1", oauth: {…}, …} ConsoleLogger.js:107 [DEBUG] 39:31.142 GraphQLAPI - configure GraphQL API {opt: {…}} ConsoleLogger.js:97 [DEBUG] 39:31.143 GraphQLAPI - create Rest instance ConsoleLogger.js:107 [DEBUG] 39:31.144 RestClient - API Options {aws_project_region: "us-east-1", aws_cognito_identity_pool_id: "us-east-1:xxxxx", aws_cognito_region: "us-east-1", oauth: {…}, aws_mobile_analytics_app_id: "xxxxx", …} ConsoleLogger.js:107 [DEBUG] 39:31.156 Interactions - configure Interactions {opt: {…}} ConsoleLogger.js:107 [DEBUG] 39:31.158 XR - configure XR {opt: {…}} ConsoleLogger.js:107 [DEBUG] 39:31.159 AbstractXRProvider - configure SumerianProvider {aws_project_region: "us-east-1", aws_cognito_identity_pool_id: "us-east-1:xxxx", aws_cognito_region: "us-east-1", oauth: {…}, aws_mobile_analytics_app_id: "xxxx", …} ConsoleLogger.js:107 [DEBUG] 39:31.161 Predictions - configure Predictions {aws_project_region: "us-east-1", aws_cognito_identity_pool_id: "us-east-1:xxxx", aws_cognito_region: "us-east-1", oauth: {…}, aws_mobile_analytics_app_id: "xxxx", …} ConsoleLogger.js:107 [DEBUG] 39:49.591 Notification - Get the token from Firebase Service duTx27RAQLaNdWhvGmRRy7:xxxxxx ConsoleLogger.js:107 [DEBUG] 39:49.592 Notification - update endpoint in push notification duTx27RAQLaNdWhvGmRRy7:xxx [Violation] Forced reflow while executing JavaScript took 51ms ConsoleLogger.js:107 [DEBUG] 39:53.612 Notification - refresh the device token with xxx ConsoleLogger.js:107 [DEBUG] 39:53.615 AWSPinpointProvider - _public record {event: {…}, provider: undefined} ConsoleLogger.js:97 [DEBUG] 39:53.629 Credentials - getting credentials ConsoleLogger.js:97 [DEBUG] 39:53.631 Credentials - picking up credentials ConsoleLogger.js:97 [DEBUG] 39:53.633 Credentials - getting new cred promise ConsoleLogger.js:97 [DEBUG] 39:53.647 Credentials - checking if credentials exists and not expired ConsoleLogger.js:97 [DEBUG] 39:53.650 Credentials - need to get a new credential or refresh the existing one ConsoleLogger.js:97 [DEBUG] 39:53.663 Credentials - no credentials for expiration check ConsoleLogger.js:97 [DEBUG] 39:53.667 AuthClass - Getting current user credentials ConsoleLogger.js:107 [DEBUG] 39:53.683 AuthClass - failed to get or parse item aws-amplify-federatedInfo SyntaxError: Unexpected token u in JSON at position 0 at JSON.parse () at AuthClass. (Auth.js:1349) at step (tslib.js:141) at Object.next (tslib.js:122) at fulfilled (tslib.js:112) at tryCallOne (core.js:37) at core.js:123 at JSTimers.js:274 at _callTimer (JSTimers.js:130) at _callImmediatesPass (JSTimers.js:181) ConsoleLogger.js:97 [DEBUG] 39:53.695 AuthClass - Getting current session ConsoleLogger.js:107 [DEBUG] 39:53.697 AuthClass - getting session failed undefined ConsoleLogger.js:97 [DEBUG] 39:53.699 Credentials - setting credentials for guest ConsoleLogger.js:107 [DEBUG] 39:55.36 Credentials - Failed to load credentials Promise {_U: 1, _V: 3, _W: Promise, _X: null} ConsoleLogger.js:107 [DEBUG] 39:55.47 Credentials - Error loading credentials TypeError: response.blob is not a function at fetch-http-handler.js:54 at tryCallOne (core.js:37) at core.js:123 at JSTimers.js:274 at _callTimer (JSTimers.js:130) at _callImmediatesPass (JSTimers.js:181) at MessageQueue.callImmediates [as _immediatesCallback] (JSTimers.js:441) at MessageQueue.__callImmediates (MessageQueue.js:387) at MessageQueue.js:135 at MessageQueue.__guard (MessageQueue.js:364) ConsoleLogger.js:107 [DEBUG] 39:55.50 AWSPinpointProvider - set credentials for analytics TypeError: response.blob is not a function at fetch-http-handler.js:54 at tryCallOne (core.js:37) at core.js:123 at JSTimers.js:274 at _callTimer (JSTimers.js:130) at _callImmediatesPass (JSTimers.js:181) at MessageQueue.callImmediates [as _immediatesCallback] (JSTimers.js:441) at MessageQueue.__callImmediates (MessageQueue.js:387) at MessageQueue.js:135 at MessageQueue.__guard (MessageQueue.js:364) ConsoleLogger.js:97 [DEBUG] 39:55.53 AWSPinpointProvider - init clients ConsoleLogger.js:107 [DEBUG] 39:55.65 AWSPinpointProvider - init clients with credentials {accessKeyId: undefined, sessionToken: undefined, secretAccessKey: undefined, identityId: undefined, authenticated: undefined} ConsoleLogger.js:107 [DEBUG] 39:55.69 EventsBuffer - Instantiating buffer with config: {bufferSize: 1000, flushSize: 100, flushInterval: 5000, resendLimit: 5, disabled: undefined, …} ConsoleLogger.js:107 [DEBUG] 39:55.118 AWSPinpointProvider - updateEndpoint error Error: No value provided for input HTTP label: EndpointId. at serializeAws_restJson1UpdateEndpointCommand$ (Aws_restJson1.js:3269) at tryCatch (runtime.js:63) at Generator.invoke [as _invoke] (runtime.js:293) at Generator.next (runtime.js:118) at tryCatch (runtime.js:63) at invoke (runtime.js:154) at runtime.js:189 at tryCallTwo (core.js:45) at doResolve (core.js:200) at new Promise (core.js:66) ExceptionsManager.js:179 [ERROR] 39:55.120 AWSPinpointProvider - updateEndpoint failed Error: No value provided for input HTTP label: EndpointId. at serializeAws_restJson1UpdateEndpointCommand$ (Aws_restJson1.js:3269) at tryCatch (runtime.js:63) at Generator.invoke [as _invoke] (runtime.js:293) at Generator.next (runtime.js:118) at tryCatch (runtime.js:63) at invoke (runtime.js:154) at runtime.js:189 at tryCallTwo (core.js:45) at doResolve (core.js:200) at new Promise (core.js:66) reactConsoleErrorHandler @ ExceptionsManager.js:179 n @ backend.js:32 registerError @ LogBox.js:148 errorImpl @ LogBox.js:59 console.error @ LogBox.js:33 ConsoleLogger._log @ ConsoleLogger.js:107 ConsoleLogger.error @ ConsoleLogger.js:163 (anonymous) @ AWSPinpointProvider.js:445 step @ tslib.js:143 (anonymous) @ tslib.js:124 (anonymous) @ tslib.js:117 tryCallTwo @ core.js:45 doResolve @ core.js:200 Promise @ core.js:66 __awaiter @ tslib.js:113 AWSPinpointProvider._handleEndpointUpdateFailure @ AWSPinpointProvider.js:431 (anonymous) @ AWSPinpointProvider.js:424 step @ tslib.js:143 (anonymous) @ tslib.js:124 rejected @ tslib.js:115 tryCallOne @ core.js:37 (anonymous) @ core.js:123 (anonymous) @ JSTimers.js:274 _callTimer @ JSTimers.js:130 _callImmediatesPass @ JSTimers.js:181 callImmediates @ JSTimers.js:441 __callImmediates @ MessageQueue.js:387 (anonymous) @ MessageQueue.js:135 __guard @ MessageQueue.js:364 flushedQueue @ MessageQueue.js:134 callFunctionReturnFlushedQueue @ MessageQueue.js:112 (anonymous) @ RNDebuggerWorker.js:2 Show 2 more frames ConsoleLogger.js:107 [DEBUG] 39:55.403 Notification - update endpoint failed Error: No value provided for input HTTP label: EndpointId. at serializeAws_restJson1UpdateEndpointCommand$ (Aws_restJson1.js:3269) at tryCatch (runtime.js:63) at Generator.invoke [as _invoke] (runtime.js:293) at Generator.next (runtime.js:118) at tryCatch (runtime.js:63) at invoke (runtime.js:154) at runtime.js:189 at tryCallTwo (core.js:45) at doResolve (core.js:200) at new Promise (core.js:66) ```

aws-exports.js

const awsmobile = {
    "aws_project_region": "us-east-1",
    "aws_cognito_identity_pool_id": "us-east-1:xxxxxxx",
    "aws_cognito_region": "us-east-1",
    "oauth": {},
    "aws_mobile_analytics_app_id": "xxxxxxxx",
    "aws_mobile_analytics_app_region": "us-east-1"
};

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

iartemiev commented 3 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:

  1. npm uninstall @aws-amplify/pushnotification @aws-amplify/core
  2. rm -rf node_modules package-lock.json
  3. npm i
  4. npx pod-install
rajashril commented 3 years ago

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.

Screenshot 2021-06-09 at 4 28 56 PM Screenshot 2021-06-09 at 4 28 39 PM
manueliglesias commented 3 years ago

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 ?

rajashril commented 3 years ago

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.

amhinson commented 3 years ago

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?

rajashril commented 3 years ago

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

  1. Sometimes endpoints are not getting created in pinpoint but we are receiving endpoint id in callback function
  2. 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.
michaelangeloio commented 3 years ago

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

rajashril commented 2 years ago

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

  1. Sometimes endpoints are not getting created in pinpoint but we are receiving endpoint id in callback function
  2. 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?

markl-vesper commented 2 years ago

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');
yuyokk commented 2 years ago

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-',
});
Screen Shot 2021-08-05 at 12 50 14 PM
markl-vesper commented 2 years ago

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

v1pz3n commented 2 years ago

Having the same issue - "aws-amplify": "^4.2.5"

any update?

yuyokk commented 2 years ago

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-',
});
Screen Shot 2021-08-05 at 12 50 14 PM

Adding mandatorySignIn to Auth fixing issue for me

Amplify.configure({
  Auth: {
    mandatorySignIn: true
  }
});
markl-vesper commented 2 years ago

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
markl-vesper commented 2 years ago

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

chrisbonifacio commented 2 years ago

Hi @rajashril 👋 are you still experiencing this issue and in need of assistance?

ashika01 commented 2 years ago

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.

BartoszKlonowski commented 2 years ago

@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.

ashika01 commented 2 years ago

did u try the suggestion above?

rob1121 commented 2 years ago

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)

image

github-actions[bot] commented 1 year ago

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.