Giter VIP home page Giter VIP logo

aws-sdk-js-tests's Introduction

aws-sdk-js-tests

Code Samples for testing AWS SDK for JavaScript.

Steps to test:

  • Fork this repo, and clone your fork.
  • Create a local branch in your workspace.
  • Update the code for testing AWS SDK for JavaScript.
  • Push code to remote branch on your fork, and share the code for reproducing the issue.

Pre-requisites

Example test for data returned by DynamoDB client:

  • Checkout main branch: git checkout main
  • Run yarn to install dependencies.

Node.js:

  • Run yarn start:node to run both v2 and v3 clients in Node.js
  • The responses returned by clients will be printed in console, and will re-run when code is updated.
  • The file being run is at packages/node/src/index.js.

Browser:

  • Run yarn start:web to start vite server with HMR.
  • The bundle will be opened in default browser, and get refreshed when code is updated.
  • The file being run is at packages/web/src/index.js.

React Native:

iOS

  • Run yarn start:ios to start local development server with iOS using React Native CLI.

Android

  • Run yarn start:android to start local development server with Android using React Native CLI.

The react-native app in simulator/emulator will refresh when code is updated. The file being run is at packages/react-native/App.js.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

aws-sdk-js-tests's People

Contributors

amazon-auto avatar dependabot-preview[bot] avatar dependabot[bot] avatar renovate[bot] avatar trivikr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

aws-sdk-js-tests's Issues

yarn:web throws error `Buffer is not defined` when client-s3 is used

Describe the bug
The yarn:web throws error Buffer is not defined when client-s3 is used

To Reproduce

  • Use @aws-sdk/client-s3 instead of @aws-sdk/client-dynamodb
  • Run yarn start:web
diff
diff --git a/packages/utils/package.json b/packages/utils/package.json
index b20093d..bcb58c0 100644
--- a/packages/utils/package.json
+++ b/packages/utils/package.json
@@ -6,7 +6,7 @@
   "main": "src/index.js",
   "dependencies": {
     "@aws-sdk/client-cognito-identity": "3.28.0",
-    "@aws-sdk/client-dynamodb": "3.28.0",
+    "@aws-sdk/client-s3": "3.28.0",
     "@aws-sdk/credential-provider-cognito-identity": "3.28.0",
     "aws-sdk": "2.990.0"
   },
diff --git a/packages/utils/src/utils.js b/packages/utils/src/utils.js
index 76eace2..22091ed 100644
--- a/packages/utils/src/utils.js
+++ b/packages/utils/src/utils.js
@@ -2,18 +2,18 @@ import AWS from "aws-sdk";
 
 import { fromCognitoIdentityPool } from "@aws-sdk/credential-provider-cognito-identity";
 import { CognitoIdentityClient } from "@aws-sdk/client-cognito-identity";
-import { DynamoDB } from "@aws-sdk/client-dynamodb";
+import { S3 } from "@aws-sdk/client-s3";
 
 import { REGION, IDENTITY_POOL_ID } from "./config.js";
 
 export const getV2Response = async (clientParams) => {
-  const client = new AWS.DynamoDB(clientParams);
-  return client.listTables().promise();
+  const client = new AWS.S3(clientParams);
+  return client.listBuckets().promise();
 };
 
 export const getV3Response = async (clientParams) => {
-  const client = new DynamoDB(clientParams);
-  return client.listTables({});
+  const client = new S3(clientParams);
+  return client.listBuckets({});
 };
 
 export const getV2BrowserResponse = async () => {

Observed behavior
Error thrown in Console:

Uncaught ReferenceError: Buffer is not defined
    at ../../node_modules/@aws-crypto/util/build/convertToBuffer.js (@aws-sdk_client-s3.js:550)
    at __require (chunk-A5ICIBVI.js:12)
    at ../../node_modules/@aws-crypto/util/build/index.js (@aws-sdk_client-s3.js:608)
    at __require (chunk-A5ICIBVI.js:12)
    at ../../node_modules/@aws-crypto/crc32/build/aws_crc32.js (@aws-sdk_client-s3.js:630)
    at __require (chunk-A5ICIBVI.js:12)
    at ../../node_modules/@aws-crypto/crc32/build/index.js (@aws-sdk_client-s3.js:953)
    at __require (chunk-A5ICIBVI.js:12)
    at @aws-sdk_client-s3.js:2509

Expected behavior
The output of listBuckets is shown in the browser tab.

yarn start:web throws error `AWS.DynamoDB is not a constructor`

Describe the bug
yarn start:web throws error AWS.DynamoDB is not a constructor

To Reproduce

  • Follow steps in README.
  • Run yarn start:web

Expected behavior
The output of listTables is shown in the browser

Screenshots
The following error is thrown in Console.log:

Uncaught (in promise) TypeError: AWS.DynamoDB is not a constructor
    at getV2Response (utils.js:10)
    at getV2BrowserResponse (utils.js:26)
    at componentV2 (index.js:24)
    at index.js:41
    at index.js:43

Additional context
This error did not appear prior to PR #94

yarn start:ios fails with Assertion failed "LoadedImage not found by num"

Describe the bug

yarn start:ios fails with Assertion failed "LoadedImage not found by num"

Steps to reproduce

Follow steps to test in react-native iOS https://github.com/aws-samples/aws-sdk-js-tests#ios

Observed behavior

Following error is thrown when generating Pods project

Generating Pods project
dyld: Assertion failed: (0 && "LoadedImage not found by num"), function findLoadedImage, file /System/Volumes/Data/SWE/macOS/BuildRoots/38cf1d983f/Library/Caches/com.apple.xbs/Sources/libdyld/dyld-852.2/dyld3/ClosureBuilder.cpp, line 713.

Expected behavior

The iOS simulator is opened which shows output of DynamoDB.listTables

yarn start:node doesn't print the console.log from src/node/index.js

Steps to repro:

$ yarn
$ yarn start:node
yarn run v1.22.0
$ nodemon src/node/index.js
[nodemon] 2.0.2
[nodemon] to restart at any time, enter `rs`
[nodemon] watching dir(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node src/node/index.js`

There's no output printed, although there's console.log in

console.log("Data returned by v2:");
console.log(JSON.stringify(response, null, 2));

Use esbuild instead of webpack for frontend for faster bundling

Is your feature request related to a problem? Please describe.
Not a big problem, but webpack is kind of slow at bundling wrt new popular bundlers like esbuild.
Benchmarks: https://github.com/evanw/esbuild#why

Describe the solution you'd like
Use esbuild for bundling frontend.
It can be combined with Snowpack too https://www.snowpack.dev/posts/2020-12-03-snowpack-3-release-candidate

Describe alternatives you've considered
Stick with webpack as it's the most popular bundler out there. Also, this repo is for testing AWS SDK for JavaScript, and it bundles the simple app within single digit seconds.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: .github/renovate.json
Error type: The renovate configuration file contains some invalid settings
Message: Invalid lockFileMaintenance.schedule: 'Invalid schedule: Failed to parse "schedule:monthly"'

React Native test is iOS throws "Require cycle" warning

Describe the bug
React Native test is iOS throws "Require cycle" warning.

To Reproduce
Run React Native set up for iOS from https://github.com/aws-samples/aws-sdk-js-tests#react-native
Notice that although output is shown for JS SDK v3 call, it also shows warning in Emulator:

Warning
WARN     Require cycle: node_modules/react-native/Libraries/Network/fetch.js -> node_modules/whatwg-fetch/dist/fetch.umd.js -> node_modules/react-native/Libraries/Network/fetch.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.

Expected behavior
No warning is shown in Emulator

Screenshots

Screenshot Screen Shot 2021-01-15 at 12 12 51 PM

React Native iOS build fails with unable to open file (in target "reactnative" in project "reactnative")

Describe the bug
React Native iOS build fails with unable to open file (in target "reactnative" in project "reactnative")

Error log
yarn run v1.22.10
$ (cd packages/react-native && yarn ios)
$ react-native run-ios
info Found Xcode workspace "reactnative.xcworkspace"
info Building (using "xcodebuild -workspace reactnative.xcworkspace -configuration Debug -scheme reactnative -destination id=DAB468CB-5D35-49F6-8B17-048E4AC1E455")
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening reactnative.xcworkspace. Run CLI with --verbose flag for more details.
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace reactnative.xcworkspace -configuration Debug -scheme reactnative -destination id=DAB468CB-5D35-49F6-8B17-048E4AC1E455

note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
error: /Users/trivikr/workspace/aws-sdk-js-tests/packages/react-native/ios/Pods/Target Support Files/Pods-reactnative/Pods-reactnative.debug.xcconfig: unable to open file (in target "reactnative" in project "reactnative") (in target 'reactnative' from project 'reactnative')
error: /Users/trivikr/workspace/aws-sdk-js-tests/packages/react-native/ios/Pods/Target Support Files/Pods-reactnative/Pods-reactnative.debug.xcconfig: unable to open file (in target "reactnative" in project "reactnative") (in target 'reactnative' from project 'reactnative')
error: /Users/trivikr/workspace/aws-sdk-js-tests/packages/react-native/ios/Pods/Target Support Files/Pods-reactnative/Pods-reactnative.debug.xcconfig: unable to open file (in target "reactnative" in project "reactnative") (in target 'reactnative' from project 'reactnative')
error: /Users/trivikr/workspace/aws-sdk-js-tests/packages/react-native/ios/Pods/Target Support Files/Pods-reactnative/Pods-reactnative.debug.xcconfig: unable to open file (in target "reactnative" in project "reactnative") (in target 'reactnative' from project 'reactnative')
warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a development team in the reactnative editor. (in target 'reactnative' from project 'reactnative')


** BUILD FAILED **


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

To Reproduce
Follow README steps for iOS https://github.com/aws-samples/aws-sdk-js-tests#ios

Expected behavior
React Native iOS build succeeds, and project is opened in iOS simulator.

Use renovate instead of dependabot

Is your feature request related to a problem? Please describe.
Automated PRs are not posted for bumping versions related to security advisories in third-party dependencies.
The PRs have to be manually posted like #95

Describe the solution you'd like
Use renovate for automated dependency updates, as it supports Yarn v2.
The request to support Yarn v2 has been pending in dependabot repo since Aug 2019 at dependabot/dependabot-core#1297, and several dependabot customers have been moving to RenovateBot.

Describe alternatives you've considered

  • Switch to npm with limited workspaces support.
  • Downgrade to yarn legacy.
  • Explore pnpm.

Reduce the time taken to build JavaScript bundle while testing react-native

Is your feature request related to a problem? Please describe.
Building JavaScript bundle while testing react-native takes lot of time

To repro, follow steps for running react-native in README

Opening exp://127.0.0.1:19000 in iOS simulator
Finished building JavaScript bundle in 22100ms.
Running application on iPhone 11.

Describe the solution you'd like
Reduce the time taken to build JavaScript bundle while testing react-native

Describe alternatives you've considered

  • Waiting for bundle to build after opening iOS simulator
  • Run in web browser using Expo Web (although it's not equivalent to testing in Simulator)
    ℹ 「wdm」: Hash: 3d00a5ec3ca1a007b399
    Version: webpack 4.39.0
    Time: 2543ms
    Built at: 03/27/2020 1:18:52 PM
    

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): lock file maintenance

Detected dependencies

bundler
packages/react-native/Gemfile
cocoapods
packages/react-native/ios/Podfile
gradle
packages/react-native/android/gradle.properties
packages/react-native/android/settings.gradle
packages/react-native/android/build.gradle
packages/react-native/android/app/build.gradle
gradle-wrapper
packages/react-native/android/gradle/wrapper/gradle-wrapper.properties
npm
package.json
packages/node/package.json
packages/react-native/package.json
packages/utils/package.json
packages/web/package.json

  • Check this box to trigger a request for Renovate to run again on this repository

The browser sample does not refresh when code is updated

Describe the bug
The browser sample does not refresh when code is updated.

To Reproduce
Follow steps for browser https://github.com/aws-samples/aws-sdk-js-tests#browser

  • Make some modification in code and save. For example, add Limit while calling listTables:
 const getV2Response = async (clientParams) => {
   const client = new AWS.DynamoDB(clientParams);
-  return client.listTables().promise();
+  return client.listTables({ Limit: 1 }).promise();
 };
 
 const getV3Response = async (clientParams) => {
   const client = new DynamoDB(clientParams);
-  return client.listTables({});
+  return client.listTables({ Limit: 1 });
 };
  • Note that the browser page does not reload, and have to be manually reloaded.

Expected behavior
The page opened in browser should reload when code is changed in the repository.

Commit Pods to reduce time required for first iOS build

Is your feature request related to a problem? Please describe.
The first iOS build takes 3 minutes to run, where as subsequent iOS builds take 53 seconds on late-2019 16-inch MBP.

This happens because the first build performs pod install step.

System Information
$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.15.7
BuildVersion:   19H114

$ sysctl -n machdep.cpu.brand_string
Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
first run
> time yarn start:ios
yarn run v1.22.10
$ (cd packages/react-native && yarn ios)
$ (cd ios && pod install) && react-native run-ios
Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
Fetching podspec for `Folly` from `../node_modules/react-native/third-party-podspecs/Folly.podspec`
Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`
Downloading dependencies
Installing CocoaAsyncSocket (7.6.4)
Installing CocoaLibEvent (1.0.0)
Installing DoubleConversion (1.1.6)
Installing FBLazyVector (0.63.4)
Installing FBReactNativeSpec (0.63.4)
Installing Flipper (0.54.0)
Installing Flipper-DoubleConversion (1.1.7)
Installing Flipper-Folly (2.3.0)
Installing Flipper-Glog (0.3.6)
Installing Flipper-PeerTalk (0.0.4)
Installing Flipper-RSocket (1.1.0)
Installing FlipperKit (0.54.0)
Installing Folly (2020.01.13.00)
Installing OpenSSL-Universal (1.0.2.20)
Installing RCTRequired (0.63.4)
Installing RCTTypeSafety (0.63.4)
Installing React (0.63.4)
Installing React-Core (0.63.4)
Installing React-CoreModules (0.63.4)
Installing React-RCTActionSheet (0.63.4)
Installing React-RCTAnimation (0.63.4)
Installing React-RCTBlob (0.63.4)
Installing React-RCTImage (0.63.4)
Installing React-RCTLinking (0.63.4)
Installing React-RCTNetwork (0.63.4)
Installing React-RCTSettings (0.63.4)
Installing React-RCTText (0.63.4)
Installing React-RCTVibration (0.63.4)
Installing React-callinvoker (0.63.4)
Installing React-cxxreact (0.63.4)
Installing React-jsi (0.63.4)
Installing React-jsiexecutor (0.63.4)
Installing React-jsinspector (0.63.4)
Installing ReactCommon (0.63.4)
Installing Yoga (1.14.0)
Installing YogaKit (1.18.1)
Installing boost-for-react-native (1.63.0)
Installing glog (0.3.5)
Generating Pods project
Integrating client project
Pod installation complete! There are 47 dependencies from the Podfile and 38 total pods installed.
info Found Xcode workspace "reactnative.xcworkspace"
info Launching iPhone 11 (iOS 14.3)
info Building (using "xcodebuild -workspace reactnative.xcworkspace -configuration Debug -scheme reactnative -destination id=DAB468CB-5D35-49F6-8B17-048E4AC1E455")
success Successfully built the app
info Installing "/Users/trivikr/Library/Developer/Xcode/DerivedData/reactnative-eqkrfboelosvurbnaxhvcfnygpim/Build/Products/Debug-iphonesimulator/reactnative.app"
info Launching "org.reactjs.native.example.reactnative"
success Successfully launched the app on the simulator
✨  Done in 182.01s.
yarn start:ios  23.70s user 24.55s system 26% cpu 3:02.20 total
second run
> time yarn start:ios
yarn run v1.22.10
$ (cd packages/react-native && yarn ios)
$ (cd ios && pod install) && react-native run-ios
Analyzing dependencies
Downloading dependencies
Generating Pods project
Integrating client project
Pod installation complete! There are 47 dependencies from the Podfile and 38 total pods installed.
info Found Xcode workspace "reactnative.xcworkspace"
info Launching iPhone 11 (iOS 14.3)
info Building (using "xcodebuild -workspace reactnative.xcworkspace -configuration Debug -scheme reactnative -destination id=DAB468CB-5D35-49F6-8B17-048E4AC1E455")
success Successfully built the app
info Installing "/Users/trivikr/Library/Developer/Xcode/DerivedData/reactnative-eqkrfboelosvurbnaxhvcfnygpim/Build/Products/Debug-iphonesimulator/reactnative.app"
info Launching "org.reactjs.native.example.reactnative"
success Successfully launched the app on the simulator
✨  Done in 52.97s.
yarn start:ios  10.90s user 6.40s system 32% cpu 53.175 total

Describe the solution you'd like
Commits iOS pods so that the first build doesn't take as much time.

This option was first explored in #62 (comment)

The command `yarn start:ios` fails with `Unable to resolve module aws-sdk` error

Describe the bug

The command yarn start:ios fails with Unable to resolve module aws-sdk error

Steps to reproduce

Follow README, and run yarn start:ios

$ node -v
v16.16.0

Observed behavior

The following error is thrown in console

 BUNDLE  ./index.js 

error: Error: Unable to resolve module aws-sdk from /Users/trivikr/workspace/aws-sdk-js-tests/packages/utils/src/utils.js: aws-sdk could not be found within the project or in these directories:
  ../../node_modules
  ../../../node_modules
  /Users/trivikr/workspace/aws-sdk-js-tests/packages/react-native/node_modules/aws-sdk
> 1 | import AWS from "aws-sdk";
    |                  ^
  2 | 
  3 | import { fromCognitoIdentityPool } from "@aws-sdk/credential-provider-cognito-identity";
  4 | import { CognitoIdentityClient } from "@aws-sdk/client-cognito-identity";
    at ModuleResolver.resolveDependency (/Users/trivikr/workspace/aws-sdk-js-tests/packages/react-native/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:158:15)
    at DependencyGraph.resolveDependency (/Users/trivikr/workspace/aws-sdk-js-tests/packages/react-native/node_modules/metro/src/node-haste/DependencyGraph.js:231:43)
    at Object.resolve (/Users/trivikr/workspace/aws-sdk-js-tests/packages/react-native/node_modules/metro/src/lib/transformHelpers.js:129:24)
    at resolve (/Users/trivikr/workspace/aws-sdk-js-tests/packages/react-native/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:33)
    at /Users/trivikr/workspace/aws-sdk-js-tests/packages/react-native/node_modules/metro/src/DeltaBundler/traverseDependencies.js:412:26
    at Array.reduce (<anonymous>)
    at resolveDependencies (/Users/trivikr/workspace/aws-sdk-js-tests/packages/react-native/node_modules/metro/src/DeltaBundler/traverseDependencies.js:411:33)
    at processModule (/Users/trivikr/workspace/aws-sdk-js-tests/packages/react-native/node_modules/metro/src/DeltaBundler/traverseDependencies.js:140:31)
    at async addDependency (/Users/trivikr/workspace/aws-sdk-js-tests/packages/react-native/node_modules/metro/src/DeltaBundler/traverseDependencies.js:230:18)
    at async Promise.all (index 1)

Expected behavior

The bundling of the react-native doesn't fail, and it provides options to make v2/v3 calls.

Screenshots

Screenshot

unable-to-resolve-module

Additional context

react-native was updated in #105

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.