Amplify-js: React native subscriptions not working

Created on 13 Feb 2020  路  7Comments  路  Source: aws-amplify/amplify-js

Describe the bug
When trying to initialize a subscription on React Native, error is thrown

Screen Shot 2020-02-13 at 1 32 17 PM

To Reproduce

  1. create a new React Native project and install amplify
$ npx react-native init rnamplify
$ cd rnamplify
$ yarn add aws-amplify
  1. Initialize a new Amplify project
$ amplify init
  1. Add an API with a basic schema
$ amplify add api

Schema

type Todo @model {
  id: ID!
  name: String!
  description: String
}
  1. Try to initialize a subscription

See this snippet or similar for code example.

Expected behavior
subscriptions work

__Details__
Reported by customer here. Tested with Amplify 2.2.2 and 2.2.4. Tried a lot of stuff before filing this bug to be sure it wasn't something on mine or the customer's machine or env.

Smartphone (please complete the following information):

  • Device: iPhone 10

Additional context
Works fine on a web project

API GraphQL PubSub React Native bug

Most helpful comment

Fix published into unstable tag tomorrow it will be published into latest tag

All 7 comments

This also fails on an Android device. By simply following the documentation, it occurs immediately.

What I am seeing is that it fails on this line with the error Buffer is not defined. I resolved this by adding the following at the start of my react-native app:

global.Buffer = require('buffer').Buffer;

For some odd reason, the buffer is not available, but by forcing it into the global scope, it does seem to work.

Nice find @callaars, thanks for the heads up and update. We're looking at a native fix for this now.

Starting to dig into this with the team

Thanks @dabit3, the issue is confirmed and I am working on a fix right now

Fix published into unstable tag tomorrow it will be published into latest tag

Thanks @elorzafe @sammartinez !!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rygo6 picture rygo6  路  3Comments

ldgarcia picture ldgarcia  路  3Comments

shinnapatthesix picture shinnapatthesix  路  3Comments

leantide picture leantide  路  3Comments

oste picture oste  路  3Comments