Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] S3Client Failed to Create Bucket in Sample Codes #1859

Closed
XunZhan opened this issue Jun 9, 2021 · 8 comments
Closed

[BUG] S3Client Failed to Create Bucket in Sample Codes #1859

XunZhan opened this issue Jun 9, 2021 · 8 comments
Assignees

Comments

@XunZhan
Copy link
Contributor

XunZhan commented Jun 9, 2021

What is the issue?
Hi, I am following the sample code S3 Create Bucket Command for JS V3: javascriptv3/example_code/s3/src/s3_createbucket.js and I did the UI in react native based on this tutorial: https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/getting-started-react-native.html

But after typing the new bucket name in the UI, I got an error to create the bucket.

How can someone reproduce this issue (if applicable)?

  1. Code Snippets:
    image

  2. UI for creating buckets
    Screen Shot 2021-06-09 at 11 21 33 AM

  3. Error Detail
    Screen Shot 2021-06-09 at 11 17 34 AM

Environment details to help us try to reproduce the issue (if applicable)

  • Operating system and version: [Windows 10 | OSX Ver 11.3.1 ]
  • SDK or tool name: [AWS SDK for JavaScript]
  • SDK or tool version:
    Screen Shot 2021-06-09 at 11 19 44 AM
@Doug-AWS
Copy link
Contributor

Doug-AWS commented Jun 9, 2021

I've assigned this issue to our JavaScript writer to review.

@XunZhan
Copy link
Contributor Author

XunZhan commented Jun 9, 2021

I've assigned this issue to our JavaScript writer to review.

Great, thanks for your help!

@Nadesri
Copy link

Nadesri commented Jun 12, 2021

I was able to reproduce, though my setup was on an Expo-managed blank project which I merged with https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascriptv3/example_code/reactnative/App.js. I think I see the issue.

not implemented
at node_modules/react-native/Libraries/Blob/URL.js:169:10 in get__hostname
at node_modules/@aws-sdk/url-parser/dist/cjs/index.js:7:4 in parseUrl
at node_modules/@aws-sdk/config-resolver/dist/cjs/EndpointsConfig.js:38:11 in getEndPointFromRegion
at [native code]:null in flushedQueue
at [native code]:null in callFunctionReturnFlushedQueue

Here is node_modules/@aws-sdk/url-parser/dist/cjs/index.js:7:4:

const { hostname, pathname, port, protocol, search } = new URL(url);

Which for some reason resolves to node_modules/react-native/Libraries/Blob/URL.js:169:10 (I don't think it should -- url-parser/package.json does not list react-native as a dependency):

  get hostname() {
    throw new Error('not implemented');
  }

This is because react-native/Blob/URL.js exports a class URL (line 115: export class URL {)

I think what we actually want is https://developer.mozilla.org/en-US/docs/Web/API/URL

@Nadesri
Copy link

Nadesri commented Jun 13, 2021

Just wanted to check back in. Is it possible that this has been broken since aws/aws-sdk-js-v3@99be092? I went through the history for React Native's Blob URL (https://github.com/facebook/react-native/commits/master/Libraries/Blob/URL.js) and it seems many fields have simply never been implemented. This commit sounds like it was meant to call WHATWG URL but I see it's resolving to React Native (tbh I don't fully understand the commit message, and the diff is kind of huge).

Others ran into similar issues calling React Native's Blob URL by accident: facebook/react-native#16434 (comment)

Suggested workaround appears to be calling https://github.com/charpeni/react-native-url-polyfill. I'm not sure yet if that's the better solution or to explicitly just call WHATWG URL.

@XunZhan
Copy link
Contributor Author

XunZhan commented Jun 14, 2021

Just wanted to check back in. Is it possible that this has been broken since aws/aws-sdk-js-v3@99be092? I went through the history for React Native's Blob URL (https://github.com/facebook/react-native/commits/master/Libraries/Blob/URL.js) and it seems many fields have simply never been implemented. This commit sounds like it was meant to call WHATWG URL but I see it's resolving to React Native (tbh I don't fully understand the commit message, and the diff is kind of huge).

Others ran into similar issues calling React Native's Blob URL by accident: facebook/react-native#16434 (comment)

Suggested workaround appears to be calling https://github.com/charpeni/react-native-url-polyfill. I'm not sure yet if that's the better solution or to explicitly just call WHATWG URL.

Hi Nadesri,

Many thanks to your observation on this issue. You are correct and it's the dependencies of react-native-url-polyfill that causes the problem. I have describe my solution and findings in a pull request. You can check my changes and readme added. Thank you so much!

@brmur
Copy link
Contributor

brmur commented Jun 14, 2021

@XunZhan Thanks for your work on this. I've tried your updates per #1864 , but unfortunately, I'm still getting the same error (see below). Are you using IOS or Windows?
image

@XunZhan
Copy link
Contributor Author

XunZhan commented Jun 16, 2021

@brmur Hmmm...that's a bit wired. Seems the not implemented error is pointing to your createBucket function. Did you do

import {  
  S3Client,  
  CreateBucketCommand,  
  DeleteBucketCommand,  
} from "@aws-sdk/client-s3";  

at top of your App.js ?
And btw, check if you have copied my createBucket() to your App.js.

@awsdocs awsdocs deleted a comment from XunZhan Jun 16, 2021
@brmur
Copy link
Contributor

brmur commented Jun 16, 2021

issue resolved. merged in #1864

@brmur brmur closed this as completed Jun 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants