From a4fd9a84d88f35a51f21636e7653f0cd67cfc944 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Oct 2023 13:42:48 -0400 Subject: [PATCH 1/2] chore(deps-dev): Bump @babel/traverse from 7.22.15 to 7.23.2 in /infra (#3965) Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.22.15 to 7.23.2. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse) --- updated-dependencies: - dependency-name: "@babel/traverse" dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- infra/pnpm-lock.yaml | 69 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 16 deletions(-) diff --git a/infra/pnpm-lock.yaml b/infra/pnpm-lock.yaml index 0106aeeac3..278fe9dedc 100644 --- a/infra/pnpm-lock.yaml +++ b/infra/pnpm-lock.yaml @@ -940,7 +940,7 @@ packages: '@babel/helpers': 7.22.15 '@babel/parser': 7.22.16 '@babel/template': 7.22.15 - '@babel/traverse': 7.22.15 + '@babel/traverse': 7.23.2 '@babel/types': 7.22.15 convert-source-map: 1.9.0 debug: 4.3.4 @@ -961,6 +961,16 @@ packages: jsesc: 2.5.2 dev: true + /@babel/generator@7.23.0: + resolution: {integrity: sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.23.0 + '@jridgewell/gen-mapping': 0.3.3 + '@jridgewell/trace-mapping': 0.3.19 + jsesc: 2.5.2 + dev: true + /@babel/helper-compilation-targets@7.22.15: resolution: {integrity: sha512-y6EEzULok0Qvz8yyLkCvVX+02ic+By2UdOhylwUOvOn9dvYc9mKICJuuU1n1XBI02YWsNsnrY1kc6DVbjcXbtw==} engines: {node: '>=6.9.0'} @@ -972,24 +982,29 @@ packages: semver: 6.3.1 dev: true + /@babel/helper-environment-visitor@7.22.20: + resolution: {integrity: sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==} + engines: {node: '>=6.9.0'} + dev: true + /@babel/helper-environment-visitor@7.22.5: resolution: {integrity: sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==} engines: {node: '>=6.9.0'} dev: true - /@babel/helper-function-name@7.22.5: - resolution: {integrity: sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==} + /@babel/helper-function-name@7.23.0: + resolution: {integrity: sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==} engines: {node: '>=6.9.0'} dependencies: '@babel/template': 7.22.15 - '@babel/types': 7.22.15 + '@babel/types': 7.23.0 dev: true /@babel/helper-hoist-variables@7.22.5: resolution: {integrity: sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.22.15 + '@babel/types': 7.23.0 dev: true /@babel/helper-module-imports@7.22.15: @@ -1029,7 +1044,7 @@ packages: resolution: {integrity: sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.22.15 + '@babel/types': 7.23.0 dev: true /@babel/helper-string-parser@7.22.5: @@ -1042,6 +1057,11 @@ packages: engines: {node: '>=6.9.0'} dev: true + /@babel/helper-validator-identifier@7.22.20: + resolution: {integrity: sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==} + engines: {node: '>=6.9.0'} + dev: true + /@babel/helper-validator-option@7.22.15: resolution: {integrity: sha512-bMn7RmyFjY/mdECUbgn9eoSY4vqvacUnS9i9vGAGttgFWesO6B4CYWA7XlpbWgBt71iv/hfbPlynohStqnu5hA==} engines: {node: '>=6.9.0'} @@ -1052,7 +1072,7 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/template': 7.22.15 - '@babel/traverse': 7.22.15 + '@babel/traverse': 7.23.2 '@babel/types': 7.22.15 transitivePeerDependencies: - supports-color @@ -1075,6 +1095,14 @@ packages: '@babel/types': 7.22.15 dev: true + /@babel/parser@7.23.0: + resolution: {integrity: sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==} + engines: {node: '>=6.0.0'} + hasBin: true + dependencies: + '@babel/types': 7.23.0 + dev: true + /@babel/plugin-syntax-async-generators@7.8.4(@babel/core@7.22.15): resolution: {integrity: sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==} peerDependencies: @@ -1209,22 +1237,22 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/code-frame': 7.22.13 - '@babel/parser': 7.22.16 - '@babel/types': 7.22.15 + '@babel/parser': 7.23.0 + '@babel/types': 7.23.0 dev: true - /@babel/traverse@7.22.15: - resolution: {integrity: sha512-DdHPwvJY0sEeN4xJU5uRLmZjgMMDIvMPniLuYzUVXj/GGzysPl0/fwt44JBkyUIzGJPV8QgHMcQdQ34XFuKTYQ==} + /@babel/traverse@7.23.2: + resolution: {integrity: sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==} engines: {node: '>=6.9.0'} dependencies: '@babel/code-frame': 7.22.13 - '@babel/generator': 7.22.15 - '@babel/helper-environment-visitor': 7.22.5 - '@babel/helper-function-name': 7.22.5 + '@babel/generator': 7.23.0 + '@babel/helper-environment-visitor': 7.22.20 + '@babel/helper-function-name': 7.23.0 '@babel/helper-hoist-variables': 7.22.5 '@babel/helper-split-export-declaration': 7.22.6 - '@babel/parser': 7.22.16 - '@babel/types': 7.22.15 + '@babel/parser': 7.23.0 + '@babel/types': 7.23.0 debug: 4.3.4 globals: 11.12.0 transitivePeerDependencies: @@ -1240,6 +1268,15 @@ packages: to-fast-properties: 2.0.0 dev: true + /@babel/types@7.23.0: + resolution: {integrity: sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-string-parser': 7.22.5 + '@babel/helper-validator-identifier': 7.22.20 + to-fast-properties: 2.0.0 + dev: true + /@balena/dockerignore@1.0.2: resolution: {integrity: sha512-wMue2Sy4GAVTk6Ic4tJVcnfdau+gx2EnG7S+uAEe+TWJFqE4YoWN4/H8MSLj4eYJKxGg26lZwboEniNiNwZQ6Q==} dev: false From 07fcfe18ce7f0da6db42833a5d8bc60571715288 Mon Sep 17 00:00:00 2001 From: Jordan Nelson Date: Fri, 20 Oct 2023 14:26:17 -0400 Subject: [PATCH 2/2] fix: remove exception during token timeout (#3939) * chore: remove exception during token timeout * fix: only call _registerDevice if device token exists * chore: update device token timeout test --- .../src/amplify_push_notifications_impl.dart | 20 +++++------ .../amplify_push_notifications_impl_test.dart | 35 +++++++++++-------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/packages/notifications/push/amplify_push_notifications/lib/src/amplify_push_notifications_impl.dart b/packages/notifications/push/amplify_push_notifications/lib/src/amplify_push_notifications_impl.dart index ae660595b6..eaf8faba52 100644 --- a/packages/notifications/push/amplify_push_notifications/lib/src/amplify_push_notifications_impl.dart +++ b/packages/notifications/push/amplify_push_notifications/lib/src/amplify_push_notifications_impl.dart @@ -341,12 +341,11 @@ abstract class AmplifyPushNotifications } Future _registerDeviceWhenConfigure() async { - late String deviceToken; - try { await _hostApi.requestInitialToken(); - deviceToken = + final deviceToken = await _bufferedTokenStream.peek.timeout(const Duration(seconds: 5)); + await _registerDevice(deviceToken); } on PlatformException catch (error) { // the error mostly like is the App doesn't have corresponding // capability to request a push notification device token @@ -355,17 +354,14 @@ abstract class AmplifyPushNotifications recoverySuggestion: 'Review the underlying exception.', underlyingException: error, ); - } on TimeoutException catch (error) { - throw PushNotificationException( - 'Timed out awaiting for device token.', - recoverySuggestion: - 'This may happen when the native apps have not been correctly configured' - ' for push notifications, review push notification configurations' - ' of the native iOS and Android apps of your Flutter project.', - underlyingException: error, + } on TimeoutException { + _logger.error( + 'Timed out awaiting for device token.' + ' This may happen when the native app has not been correctly configured' + ' for push notifications. Review push notification configurations' + ' of the native iOS and Android apps of your Flutter project.', ); } - await _registerDevice(deviceToken); } void _foregroundNotificationListener( diff --git a/packages/notifications/push/amplify_push_notifications/test/amplify_push_notifications_impl_test.dart b/packages/notifications/push/amplify_push_notifications/test/amplify_push_notifications_impl_test.dart index a805064ad8..4982136ffa 100644 --- a/packages/notifications/push/amplify_push_notifications/test/amplify_push_notifications_impl_test.dart +++ b/packages/notifications/push/amplify_push_notifications/test/amplify_push_notifications_impl_test.dart @@ -1,7 +1,6 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import 'dart:async'; import 'dart:convert'; import 'package:amplify_core/amplify_core.dart'; @@ -269,21 +268,20 @@ void main() { ); }); - test('configure should fail if timed out awaiting for device token', + test('configure should log an error if timed out awaiting for device token', () async { - expect( - plugin.configure( - authProviderRepo: authProviderRepo, - config: config, - ), - throwsA( - isA().having( - (o) => o.underlyingException, - 'underlyingException', - isA(), - ), - ), + when(mockPushNotificationsHostApi.getLaunchNotification()).thenAnswer( + (_) async => standardAndroidPushMessage.cast(), + ); + final loggerPlugin = InMemoryLogger(); + AmplifyLogger.category(Category.pushNotifications) + .registerPlugin(loggerPlugin); + await plugin.configure( + authProviderRepo: authProviderRepo, + config: config, ); + expect(loggerPlugin.logs.length, 1); + expect(loggerPlugin.logs.first.level, LogLevel.error); }); }); test('should fail configure when registering device is unsuccessful', @@ -589,3 +587,12 @@ void main() { ); }); } + +class InMemoryLogger implements AWSLoggerPlugin { + final List logs = []; + + @override + void handleLogEntry(LogEntry logEntry) { + logs.add(logEntry); + } +}