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.44k stars 2.13k forks source link

Cache API broken/undefined in 4.3.37 #10567

Closed joebernard closed 2 years ago

joebernard commented 2 years ago

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Cache

Amplify Categories

storage

Environment information

``` # Put output below this line System: OS: macOS 12.6 CPU: (10) arm64 Apple M1 Max Memory: 784.41 MB / 64.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node Yarn: 1.22.19 - ~/.yarn/bin/yarn npm: 8.3.0 - ~/.nvm/versions/node/v16.13.1/bin/npm Watchman: 2022.03.14.00 - /opt/homebrew/bin/watchman Browsers: Chrome: 106.0.5249.119 Firefox: 106.0.1 Safari: 16.0 npmPackages: @apollo/client: 3.7.1 => 3.7.1 @apollo/client/cache: undefined () @apollo/client/core: undefined () @apollo/client/errors: undefined () @apollo/client/link/batch: undefined () @apollo/client/link/batch-http: undefined () @apollo/client/link/context: undefined () @apollo/client/link/core: undefined () @apollo/client/link/error: undefined () @apollo/client/link/http: undefined () @apollo/client/link/persisted-queries: undefined () @apollo/client/link/retry: undefined () @apollo/client/link/schema: undefined () @apollo/client/link/subscriptions: undefined () @apollo/client/link/utils: undefined () @apollo/client/link/ws: undefined () @apollo/client/react: undefined () @apollo/client/react/components: undefined () @apollo/client/react/context: undefined () @apollo/client/react/hoc: undefined () @apollo/client/react/hooks: undefined () @apollo/client/react/parser: undefined () @apollo/client/react/ssr: undefined () @apollo/client/testing: undefined () @apollo/client/testing/core: undefined () @apollo/client/utilities: undefined () @apollo/client/utilities/globals: undefined () @aws-amplify/auth: 4.6.3 => 4.6.3 (4.6.8) @babel/core: 7.12.9 => 7.12.9 (7.15.5, 7.18.10, 7.17.9, 7.18.9) @babel/runtime: 7.12.5 => 7.12.5 (7.17.9) @bugsnag/plugin-react-navigation: 7.18.0 => 7.18.0 @bugsnag/react-native: 7.18.1 => 7.18.1 @bugsnag/source-maps: 2.3.1 => 2.3.1 @expo/react-native-action-sheet: 4.0.0 => 4.0.0 @notifee/react-native: 5.7.0 => 5.7.0 @react-native-async-storage/async-storage: 1.17.10 => 1.17.10 @react-native-camera-roll/camera-roll: 5.0.4 => 5.0.4 @react-native-clipboard/clipboard: 1.11.1 => 1.11.1 @react-native-community/checkbox: 0.5.12 => 0.5.12 @react-native-community/eslint-config: 3.0.0 => 3.0.0 @react-native-community/hooks: 2.8.1 => 2.8.1 @react-native-community/netinfo: 9.3.6 => 9.3.6 @react-native-community/push-notification-ios: 1.10.1 => 1.10.1 @react-native-firebase/app: 15.4.0 => 15.4.0 @react-native-firebase/messaging: 15.4.0 => 15.4.0 @react-native-masked-view/masked-view: 0.2.8 => 0.2.8 @react-native-picker/picker: 2.4.8 => 2.4.8 @react-navigation/bottom-tabs: 6.4.0 => 6.4.0 @react-navigation/elements: 1.3.6 => 1.3.6 @react-navigation/native: 6.0.13 => 6.0.13 @react-navigation/native-stack: 6.9.1 => 6.9.1 @react-navigation/stack: 6.3.3 => 6.3.3 @shopify/flash-list: 1.3.1 => 1.3.1 @types/babel__core: 7.1.19 => 7.1.19 @types/eslint: 8.4.1 => 8.4.1 @types/jest: 28.1.8 => 28.1.8 @types/lodash.debounce: 4.0.7 => 4.0.7 @types/lodash.throttle: 4.1.7 => 4.1.7 @types/prop-types: 15.7.5 => 15.7.5 @types/react: 17.0.39 => 17.0.39 @types/react-native: 0.67.8 => 0.67.8 @types/react-native-vector-icons: 6.4.12 => 6.4.12 @types/react-native-wheel-pick: 1.1.2 => 1.1.2 @types/react-test-renderer: 17.0.0 => 17.0.0 @types/uuid: 8.3.4 => 8.3.4 HelloWorld: 0.0.1 ReactNativeRootToast: 0.0.1 amazon-cognito-identity-js: 5.2.12 => 5.2.12 (5.2.10) appcenter: 4.4.5 => 4.4.5 appcenter-analytics: 4.4.5 => 4.4.5 appcenter-crashes: 4.4.5 => 4.4.5 assert: 2.0.0 => 2.0.0 async-mutex: 0.4.0 => 0.4.0 aws-amplify: 4.3.37 => 4.3.37 aws-appsync-auth-link: 3.0.7 => 3.0.7 aws-appsync-subscription-link: 3.1.0 => 3.1.0 babel-jest: 28.1.3 => 28.1.3 babel-plugin-module-resolver: 4.1.0 => 4.1.0 babel-plugin-transform-remove-console: 6.9.4 => 6.9.4 eslint: 7.14.0 => 7.14.0 eslint-plugin-flowtype: 8.0.3 => 8.0.3 (2.50.3) example: 0.0.1 expo: 45.0.6 => 45.0.6 expo-av: 11.2.3 => 11.2.3 expo-blur: 11.2.0 => 11.2.0 expo-image-manipulator: 10.4.0 => 10.4.0 expo-navigation-bar: 1.3.0 => 1.3.0 expo-secure-store: 11.3.0 => 11.3.0 expo-splash-screen: 0.16.2 => 0.16.2 expo-system-ui: 1.3.0 => 1.3.0 expo-video-thumbnails: 6.4.0 => 6.4.0 exponential-backoff: 3.1.0 => 3.1.0 ffmpeg-kit-react-native: 4.5.2 => 4.5.2 graphql: 16.6.0 => 16.6.0 (15.8.0) hermes-inspector-msggen: 1.0.0 i18next: 21.9.1 => 21.9.1 intl-pluralrules: 1.3.1 => 1.3.1 jest: 28.1.3 => 28.1.3 lodash.debounce: 4.0.8 => 4.0.8 lodash.throttle: 4.1.1 => 4.1.1 metro-react-native-babel-preset: 0.67.0 => 0.67.0 moment-timezone: 0.5.38 => 0.5.38 patch-package: 6.5.0 => 6.5.0 pexels: 1.4.0 => 1.4.0 piexifjs: 1.0.6 => 1.0.6 postinstall-postinstall: 2.1.0 => 2.1.0 prop-types: 15.8.1 => 15.8.1 (15.7.2) react: 17.0.2 => 17.0.2 react-dom: 16.12.0 => 16.12.0 react-fast-compare: 3.2.0 => 3.2.0 react-hook-thunk-reducer: https://github.com/nutstick/react-hook-thunk-reducer.git => 0.2.4 react-i18next: 11.18.5 => 11.18.5 react-native: 0.68.2 => 0.68.2 react-native-adjust: 4.32.0 => 4.32.0 react-native-anchor-point: 1.0.6 => 1.0.6 react-native-animatable: 1.3.3 => 1.3.3 react-native-background-fetch: 4.1.5 => 4.1.5 react-native-boring-avatars: 1.0.1 => 1.0.1 react-native-boring-avatars-example: 0.0.1 react-native-code-push: 7.0.5 => 7.0.5 react-native-config: 1.4.11 => 1.4.11 react-native-country-picker-modal: 2.0.0 => 2.0.0 react-native-date-picker: 4.2.5 => 4.2.5 react-native-device-info: 10.3.0 => 10.3.0 react-native-draggable: 3.3.0 => 3.3.0 react-native-fast-image: 8.6.1 => 8.6.1 react-native-fbsdk-next: 10.1.0 => 10.1.0 react-native-fs: 2.20.0 => 2.20.0 react-native-gesture-handler: 2.8.0 => 2.8.0 react-native-get-random-values: 1.8.0 => 1.8.0 react-native-haptic-feedback: 1.14.0 => 1.14.0 react-native-headphone-detection: 1.3.0 => 1.3.0 react-native-image-crop-picker: 0.38.1 => 0.38.1 react-native-image-size: 1.1.3 => 1.1.3 react-native-localize: 2.2.3 => 2.2.3 react-native-make-it-rain: https://github.com/convective/react-native-make-it-rain.git => 1.1.1 react-native-orientation-locker: 1.5.0 => 1.5.0 react-native-pager-view: 6.0.1 => 6.0.1 react-native-permissions: 3.6.1 => 3.6.1 react-native-progress: 5.0.0 => 5.0.0 react-native-reanimated: 2.12.0 => 2.12.0 react-native-restart: 0.0.24 => 0.0.24 react-native-root-toast: 3.4.0 => 3.4.0 react-native-safe-area-context: 4.4.1 => 4.4.1 react-native-safe-area-view: 2.0.0 => 2.0.0 react-native-screens: 3.18.2 => 3.18.2 react-native-secure-storage: 0.1.2 => 0.1.2 react-native-share: 7.9.1 => 7.9.1 react-native-sms-verifycode: 2.4.3 => 2.4.3 react-native-store-review: 0.3.0 => 0.3.0 react-native-svg: 13.4.0 => 13.4.0 (12.4.4) react-native-tab-view: 3.3.0 => 3.3.0 react-native-ticker: 5.1.0 => 5.1.0 react-native-url-polyfill: 1.3.0 => 1.3.0 react-native-vector-icons: 9.2.0 => 9.2.0 react-native-video-cache: 2.7.3 => 2.7.3 react-native-view-shot: 3.4.0 => 3.4.0 react-native-vision-camera: 2.15.1 => 2.15.1 react-native-volume-manager: 1.2.1 => 1.2.1 react-native-webview: 11.23.1 => 11.23.1 react-native-wheel-pick: 1.2.0 => 1.2.0 react-navigation-props-mapper: 3.0.0 => 3.0.0 react-test-renderer: 17.0.2 => 17.0.2 ts-jest: 29.0.3 => 29.0.3 typescript: 4.8.4 => 4.8.4 use-debounce: 8.0.4 => 8.0.4 uuid: 9.0.0 => 9.0.0 (3.4.0, 3.3.2, 8.3.2, 7.0.3) zustand: 4.1.3 => 4.1.3 npmGlobalPackages: corepack: 0.10.0 eslint: 8.14.0 npm: 8.3.0 prettier: 2.6.2 serverless: 3.23.0 ```

Describe the bug

Cache is undefined when importing from aws-amplify v4.3.37.

import {Cache} from 'aws-amplify';

Cache.setItem('foo', bar);

Cannot read property 'setItem' of undefined

The resolution is to roll back to v4.3.33 where this call still works. It appears to have been introduced in this PR: https://github.com/aws-amplify/amplify-js/pull/10305

Expected behavior

Cache should be defined after importing.

Reproduction steps

yarn add aws-amplify@4.3.37

import {Cache} from 'aws-amplify';

Cache.setItem('foo', bar);

Code Snippet

// Put your code below this line.
import {Cache} from 'aws-amplify';

Cache.setItem('foo', bar);

Log output

``` // Put your logs below this line Cannot read property 'setItem' of undefined ```

aws-exports.js

No response

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

tannerabread commented 2 years ago

Hi @joebernard The team is aware of this issue and a fix for this issue is implemented and being released with Amplify@v5 via PR #10546

v5 should be released within the next few weeks

tannerabread commented 2 years ago

@joebernard Closing this as resolved. The fix for this went out pre-v5 with v4.3.43. Let me know if you are still experiencing this issue after upgrading to 4.3.43 and I will re-open to assess further.

Thank you!