Describe the bug
If I re-install my app enough times it hits the 10 endpoint limit and does not clear unused ones. I've only installed this app on a single test device so there should be plenty of unused endpoints to delete.
It seems this line isn't recognizing the error message correctly and not attempting to clear out the old endpoints:
My IAM policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"mobiletargeting:GetUserEndpoints",
"mobiletargeting:PutEvents",
"mobiletargeting:UpdateEndpoint"
],
"Resource": "arn:aws:mobiletargeting:*:*:apps/*"
}
]
}
To Reproduce
Install the app on a device more than 10 times.
Expected behavior
Amplify should clear old endpoints as mentioned in the docs.
Environment
System:
OS: macOS 10.15.4
CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
Memory: 28.12 MB / 32.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.11.3 - ~/.nvm/versions/node/v10.15.3/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Browsers:
Chrome: 81.0.4044.113
Firefox: 75.0
Safari: 13.1
npmPackages:
@aws-amplify/analytics: ^3.1.7 => 3.1.7
@aws-amplify/auth: ^3.2.4 => 3.2.4
@aws-amplify/cache: ^3.1.7 => 3.1.7
@aws-amplify/core: ^3.2.4 => 3.2.4
@aws-amplify/pushnotification: ^3.0.8 => 3.0.8
@aws-amplify/storage: ^3.1.7 => 3.1.7
@babel/core: ^7.6.2 => 7.9.0
@babel/runtime: ^7.6.2 => 7.9.2
@react-native-community/async-storage: 1.9.0 => 1.9.0
@react-native-community/eslint-config: ^0.0.5 => 0.0.5
@react-native-community/masked-view: ^0.1.9 => 0.1.9
@react-native-community/netinfo: ^5.7.1 => 5.7.1
@react-native-community/push-notification-ios: 1.1.1 => 1.1.1
@types/react: 16.9.34 => 16.9.34
amazon-cognito-identity-js: 4.2.1 => 4.2.1
apollo-cache: ^1.3.4 => 1.3.4
apollo-cache-inmemory: ^1.6.5 => 1.6.5
apollo-client: 2.6.8 => 2.6.8
apollo-link: ^1.2.14 => 1.2.14
apollo-link-http: ^1.5.17 => 1.5.17
apollo-utilities: ^1.3.3 => 1.3.3
aws-appsync: ^3.0.2 => 3.0.2
aws-appsync-auth-link: ^2.0.1 => 2.0.1
aws-appsync-react: ^3.0.2 => 3.0.2
aws-appsync-subscription-link: ^2.0.1 => 2.0.1
babel-jest: ^24.9.0 => 24.9.0
bugsnag-react-native: ^2.23.7 => 2.23.7
eslint: ^6.5.1 => 6.8.0
graphql: 15.0.0 => 15.0.0
graphql-tag: ^2.10.3 => 2.10.3
jest: ^24.9.0 => 24.9.0
lodash.clonedeep: ^4.5.0 => 4.5.0
lodash.debounce: ^4.0.8 => 4.0.8
lodash.flowright: ^3.5.0 => 3.5.0
lodash.uniqby: ^4.7.0 => 4.7.0
metro-react-native-babel-preset: ^0.58.0 => 0.58.0
moment: ^2.24.0 => 2.24.0
moment-timezone: ^0.5.28 => 0.5.28
native-base: ^2.13.12 => 2.13.12
prop-types: ^15.7.2 => 15.7.2
react: 16.11.0 => 16.11.0
react-apollo: ^3.1.5 => 3.1.5
react-dom: ^16.12.0 => 16.13.1
react-native: 0.62.2 => 0.62.2
react-native-animatable: ^1.3.3 => 1.3.3
react-native-camera: ^3.22.1 => 3.22.1
react-native-circular-progress: 1.3.6 => 1.3.6
react-native-config: 1.0.0 => 1.0.0
react-native-country-picker-modal: ^1.10.0 => 1.10.0
react-native-device-info: ^5.5.4 => 5.5.4
react-native-fast-image: ^8.1.5 => 8.1.5
react-native-fs: ^2.16.6 => 2.16.6
react-native-gesture-handler: ^1.6.1 => 1.6.1
react-native-haptic-feedback: ^1.9.0 => 1.9.0
react-native-orientation-locker: ^1.1.8 => 1.1.8
react-native-permissions: ^2.1.1 => 2.1.1
react-native-progress: ^4.1.2 => 4.1.2
react-native-reanimated: ^1.8.0 => 1.8.0
react-native-safe-area-context: ^0.7.3 => 0.7.3
react-native-safe-area-view: ^1.0.0 => 1.0.0
react-native-screens: ^2.4.0 => 2.4.0
react-native-share: 3.2.0 => 3.2.0
react-native-svg: ^12.1.0 => 12.1.0
react-native-svg-animated-linear-gradient: https://github.com/joebernard/react-native-svg-animated-linear-gradient.git => 0.3.4
react-native-tab-view: ^2.14.0 => 2.14.0
react-native-vector-icons: ^6.6.0 => 6.6.0
react-native-video: ^5.0.2 => 5.0.2
react-native-webview: 9.2.1 => 9.2.1
react-navigation: ^4.3.7 => 4.3.7
react-navigation-props-mapper: ^1.0.4 => 1.0.4
react-navigation-stack: ^2.3.11 => 2.3.11
react-navigation-tabs: ^2.8.11 => 2.8.11
react-test-renderer: 16.11.0 => 16.11.0
uuid: ^3.4.0 => 3.4.0
npmGlobalPackages:
@aws-amplify/cli: 4.6.0
gatsby-cli: 2.8.18
ios-deploy: 1.10.0
npm: 6.11.3
react-native-create-library: 3.1.2
serverless: 1.67.0
Smartphone (please complete the following information):
Additional context
The issue is also discussed in #1378.
I think I've got to the bottom of the problem. It is here - https://github.com/aws-amplify/amplify-js/blob/14f1ef9b88bc5cb99ec0a47308d3fb9cf4c89102/packages/analytics/src/Providers/AWSPinpointProvider.ts#L437
err doesn't have a field statusCode. Instead status code is sitting in err.$metadata.httpStatusCode
I have come up with a workaround that solves the issue for me. It needs to be executed prior to calling Amplify.configure (TypeScript):
import { AWSPinpointProvider } from "aws-amplify";
const pinPointProviderPrototype = AWSPinpointProvider.prototype as any;
const baseHandleEndpointUpdateFailure = pinPointProviderPrototype._handleEndpointUpdateFailure as Function;
pinPointProviderPrototype._handleEndpointUpdateFailure = function (failureData: any) {
if (failureData?.err) {
failureData.err.statusCode = failureData.err.$metadata?.httpStatusCode;
}
return baseHandleEndpointUpdateFailure.call(this, failureData);
}
@undefobj Any thoughts on this one? It seems to be a regression.
@joebernard thanks for reporting the bug and thank you to @ilyalukyanov for the solution.
We will test it on our end and will release a fix shortly.
This should be fixed now in the latest unstable version of Amplify (npm i aws-amplify@unstable) and will be part of the next stable release.
This issue is resolved in the latest stable versions of analytics and auth. Installing below versions resolved the issue for me.
"@aws-amplify/analytics": "^3.2.5",
"@aws-amplify/auth": "^3.3.3"
Most helpful comment
This should be fixed now in the latest unstable version of Amplify (
npm i aws-amplify@unstable) and will be part of the next stable release.