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

Exception Loading Root with JSON Descriptor containing Enums #964

Closed
dharmusharma1981 opened this issue Dec 21, 2017 · 8 comments
Closed

Comments

@dharmusharma1981
Copy link

protobuf.js version: <6.8.3>

Exception ExceptionsManager.js:65 (intermediate value)(intermediate value)(intermediate value) is not a function ``` Im trying to load json file which contains enums ` "PlatformType": { "values": { "UNKNOWN": 0, "RAY_DESKTOP": 1, "RAY_MOBILE": 2 } },

after drilling down the code

i find this Enum.fromJson is undefined in the libarary
![screen shot 2017-12-21 at 2 30 46 pm](https://user-images.githubusercontent.com/10889920/34277738-e9c17c52-e65b-11e7-927a-a5addfcca539.png

```
@dcodeIO
Copy link
Member

dcodeIO commented Dec 21, 2017

That's strange, Enum.fromJSON should be there. What's the environment you are using protobuf.js in? Anything special?

@dharmusharma1981
Copy link
Author

dharmusharma1981 commented Dec 22, 2017

im using react native,
Used pbjs to convert proto to json format
with node

@dcodeIO
Copy link
Member

dcodeIO commented Dec 22, 2017

im using react native

I see. There have been similar issues in the past and iirc these are caused by recursive dependencies in the sources (enum.js requires something that again requires enum.js) that only react native isn't able to solve for some reason. This can be solved, usually, but requires checking all the dependencies and some reordering. Have you tried using the dist files instead?

@dharmusharma1981
Copy link
Author

dist files work fine

@adambom
Copy link

adambom commented Jan 3, 2018

I'm seeing this as well (version 0.51.0 of react-native). The circular dependency arises when namespace.js requires enum.js and enum.js requires namespace.js.

@dharmusharma1981 how were you able to import the dist files into the app?

@adambom
Copy link

adambom commented Jan 3, 2018

Downgrading to version 6.8.0 worked for me (I was on 6.8.3).

leonardpauli added a commit to leonardpauli/protobuf.js that referenced this issue Mar 5, 2018
leonardpauli added a commit to leonardpauli/protobuf.js that referenced this issue Mar 5, 2018
@leonardpauli
Copy link
Contributor

for quick fix until PR merged:

yarn add LeonardPauli/protobuf.js#964-enum-circular-dep-react-native

(in essence 7 char diff from 6.8.6)

@pbaer
Copy link

pbaer commented Apr 4, 2018

@dcodeIO any plans to merge this PR? We are blocked from using protobufjs in React Native due to this issue.

leonardpauli added a commit to leonardpauli/protobuf.js that referenced this issue Apr 5, 2018
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

5 participants