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

React native: could not create Assembly io().connect #1770

Closed
dgaido opened this issue Aug 7, 2019 · 3 comments
Closed

React native: could not create Assembly io().connect #1770

dgaido opened this issue Aug 7, 2019 · 3 comments
Assignees
Labels
Bug Help Wanted Indicates that we’d especially appreciate community input in this issue React Native

Comments

@dgaido
Copy link

dgaido commented Aug 7, 2019

Hi, I am trying to integrate your service, I've got everything working in react native (expo) with XHRUpload, but I am now trying to get Transloadit upload to work.
My backend creates and returns the required parameters (including the signature and referencing a template id) to the frontend which then:

const uppy = Uppy({ autoProceed: true, debug: true });
    uppy.use(Transloadit, {
      service: 'https://api2.transloadit.com',
      params,
      waitForEncoding: false,
      waitForMetadata: false,
      importFromUploadURLs: false,
      alwaysRunAssembly: false,
      signature,
      fields,
    });
    await uppy.addFile({
      source: 'React Native',
      name: video.uri,
      data: await readLocalFileAsBlob(video.uri),
    });

As soon as the code hits addFile, I receive this error:

[Uppy] [04:26:57] [Transloadit] _onError in upload cjz0zo7qf0000uesttruospjn
[Uppy] [04:26:57] [TypeError: Transloadit: Could not create Assembly: undefined is not an object (evaluating 'io().connect')]
[Uppy] [04:26:57] Transloadit: Could not create Assembly: undefined is not an object (evaluating 'io().connect') 

[Unhandled promise rejection: TypeError: undefined is not an object (evaluating '_this3.uppy.log')]
- node_modules/@uppy/core/lib/index.js:600:24 in <unknown>
- node_modules/promise/setimmediate/core.js:37:14 in tryCallOne
- ... 9 more stack frames from framework internals

I dug into the code and found a reference to socket.io-client, which I installed with yarn, but the error persist. Why? Why is it even trying to connect to a socket given I set all the options to async?

What is this cryptic message?

Thanks for any help

@dgaido
Copy link
Author

dgaido commented Aug 9, 2019

I have fixed this by changing this line:

var io = requireSocketIo;

to:

import io from 'socket.io-client';

From the socket.io docs, looks like they changed the way the library needs to be pulled in.
Do you want me to create a pull request?

@arturi
Copy link
Contributor

arturi commented Aug 13, 2019

A PR would be nice, but we use CommonJS require in our source code, we can’t just use import, without switching everything to it. The solution would probably be something like .default here, what do you think, @goto-bus-stop?

@goto-bus-stop
Copy link
Contributor

The socket.io-client package doesn't have an ES modules build and doesn't use a .default property. require('socket.io-client') should work in normal situations. I tried manually bundling an Uppy project with the Metro bundler that React Native uses, and it worked fine in the browser, so I'm not sure where the problem is…

@arturi arturi added the Help Wanted Indicates that we’d especially appreciate community input in this issue label Jan 15, 2020
@ifedapoolarewaju ifedapoolarewaju removed their assignment May 20, 2020
@arturi arturi closed this as completed Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Help Wanted Indicates that we’d especially appreciate community input in this issue React Native
Projects
None yet
Development

No branches or pull requests

4 participants