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

JSON.Parse exception with debugAppMode: true #45

Open
azixMcAze opened this issue Aug 11, 2021 · 1 comment
Open

JSON.Parse exception with debugAppMode: true #45

azixMcAze opened this issue Aug 11, 2021 · 1 comment

Comments

@azixMcAze
Copy link

When testing the Furioos SDK with debugAppMode: true, an exception is thrown when the sign-in message ({"type" :"signIn","peerName" :"SDK_APP"}) is received from the application:

Uncaught SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data
    _wsOnMessage SDKDebug.js:33
    onmessage SDKDebug.js:12
    SDKDebug SDKDebug.js:12
    Player Player.js:112
    [1]< index.js:6
    o _prelude.js:1
    r _prelude.js:1
    <anonymous> _prelude.js:1

It seems that JSON.parse is passed an ArrayBuffer instead of a string in _wsOnMessage

This can be fixed by decoding the ArrayBuffer before parsing its content:

  decoder = new TextDecoder()

  _wsOnMessage(event) {
    const str = this.decoder.decode(event.data);
    const msg = JSON.parse(str);
...

However, the message will be discarded because it is not recognized by the following test:

...
  if (msg.type == "furioos" && msg.task == "sdk") {
...
@pho3nixf1re
Copy link

I can confirm the same behavior. Are there any workarounds?

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

2 participants