Amplify-js: AppSync Subscription not working when using cognito user pool for authentication

Created on 7 Nov 2018  路  4Comments  路  Source: aws-amplify/amplify-js

Describe the bug
When using 'AMAZON_COGNITO_USER_POOLS' as authentication type. API.graphql(...) subscription will failed.
Error:

TypeError: In this environment the sources for assign MUST be an object. This error is a performance optimization and not spec compliant.

I look into the source code and this error is coming from API.js line 564:
additionalheaders = __assign({}, (authenticationType === 'API_KEY' && {'x-amz-subscriber-id': this.clientIdentifier}));
Since the authenticationType is 'AMAZON_COGNITO_USER_POOLS', the second argument will be false thus causing the Object assign TypeError.

I can subscribe to appsync successfully after commented out the code above.

This error only occured on React Native project.
I have same code running on Web based React project without any issue.

To Reproduce
Steps to reproduce the behavior:

  1. Set aws_appsync_authenticationType to 'AMAZON_COGNITO_USER_POOLS',
  2. Subscribe to appsync subscription using API.graphql(...)
  3. See error

Expected behavior
Subscribe to appsync subscription successfully

Environment:
MacOS 10.14
xcode 10.1

Project dependency:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

API bug

All 4 comments

I reproduced the problem on the simulator, working on PR to fix the problem

@derrenw is available a new unstable version. I've just tried it, and is working for me.
[email protected]

@elorzafe sorry for late reply. i confirm this issue have been resolved in latest [email protected] release. Thanks for the support!

Was this page helpful?
0 / 5 - 0 ratings