amplify-js: Storage broken in amplify-js 3.x

Describe the bug After updating to 3.x we cannot use Amplify Storage. We are using named imports and Storage has been configured and in aws-exports.js we have the following lines (auto-generated) in relation to storage:

"aws_user_files_s3_bucket": "bucketname-prod",
"aws_user_files_s3_bucket_region": "us-east-1"

There’s no AWSS3 value in that aws-exports.js file, and I’m frankly confused what is the right setup. Documentation seems to be related to 2.x and manual configuration is not in use here and was not needed in 2.x either.

The error is:

[Error] Unhandled Promise Rejection: No plugin found in Storage for the provider
	(anonymous function)
	rejectPromise
	rejectPromiseWithFirstResolvingFunctionCallCheck
	reject
	(anonymous function) (7.11d9e661.chunk.js:2:72188)
	(anonymous function) (7.11d9e661.chunk.js:2:69807)
	(anonymous function) (7.11d9e661.chunk.js:2:68846)
	Promise
	ee (7.11d9e661.chunk.js:2:68606)
	(anonymous function)
	u (6.9289253a.chunk.js:2:1029567)
	(anonymous function) (6.9289253a.chunk.js:2:1029317)
	r (6.9289253a.chunk.js:2:58397)
	s (6.9289253a.chunk.js:2:58601)
	(anonymous function) (6.9289253a.chunk.js:2:58660)
	Promise
	(anonymous function) (6.9289253a.chunk.js:2:58551)
	(anonymous function) (14.9a8a693a.chunk.js:1:11039)
	os (6.9289253a.chunk.js:2:987807)
	mu (6.9289253a.chunk.js:2:1006949)
	(anonymous function) (6.9289253a.chunk.js:2:1025266)
	Zs (6.9289253a.chunk.js:2:998224)
	Zs
	(anonymous function) (6.9289253a.chunk.js:2:949685)
	(anonymous function) (6.9289253a.chunk.js:2:1025266)
	Go (6.9289253a.chunk.js:2:949631)
	qo (6.9289253a.chunk.js:2:949566)
	Ks (6.9289253a.chunk.js:2:995083)
	ga (6.9289253a.chunk.js:2:966801)
	ga
	next (14.9a8a693a.chunk.js:1:40963)
	b (6.9289253a.chunk.js:2:1076404)
	w (6.9289253a.chunk.js:2:1076907)
	value (6.9289253a.chunk.js:2:1077460)
	b (6.9289253a.chunk.js:2:1076404)
	w (6.9289253a.chunk.js:2:1076907)
	value (6.9289253a.chunk.js:2:1077460)
	(anonymous function) (6.9289253a.chunk.js:2:353163)
	(anonymous function)
[Error] Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'i.get')
	dispatchException (6.9289253a.chunk.js:2:1033029)
	(anonymous function) (6.9289253a.chunk.js:2:1029238)
	r (6.9289253a.chunk.js:2:58397)
	u (6.9289253a.chunk.js:2:58637)
	promiseReactionJob
[Log] [DEBUG] 18:16.913 StorageClass - No plugin found with providerName – "AWSS3" (6.9289253a.chunk.js, line 2)

It seems to point to Storage.get is undefined which is the only Storage feature we are currently using.

This only happened in our production environment, development had no errors, which seems to point to an issue with web pack (this is a create-react-app which is not ejected) tree-shaking or something.

  • OS: MacOS
  • Browser Chrome
  • Version 80
  • amplify-js 3.0.7

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 17 (7 by maintainers)

Most upvoted comments

It does work on my production build also, sorry about that.

On a related note to that, it is weird that locally when not creating the production build it did work, but that may be npm cache?

Also, a nice side effect of this major version update is that my main chunk was shrunk and is now HALF the size (was ~750kb and it’s now ~367kb) as it seems web pack is now able to proper tree shake this package. I always had named imports, but for some reason it may have imported the entire package.

Thanks again!

This is because tree shaking is activated only in prod builds (typical create-react-app webpack configs) and local development builds do not have any tree shaking applied, so if you have add aws-amplify package, you have all the categories in your local development “build”

Yes, that was my thought also right after sending my last message.

May I suggest adding a better console output message when Storage fails due to this error and tell the dev to maybe ensure doing Storage.configure (of course for all features / APIs).

Happy to report, that fixed it. So yes, this should be added to breaking change. 2 lines needed, import the exports file and Storage.configure.

Thanks for your quick help!