3box / 3box-js

3Box JavaScript SDK: User identities, storage, messaging
MIT License
207 stars 65 forks source link

3box js is incompatible with Crisp (chat client) #699

Open JasoonS opened 4 years ago

JasoonS commented 4 years ago

Describe the bug 3box throws this error when running Box.openBox or Box.openSpace on a website that has the crisp client installed.

The exact error message that appears if crisp is used on the website is:

[ERROR] orbit-db: [Error: The object passed has circular references]

To Reproduce Steps to reproduce the behavior:

  1. Load any app that uses 3box locally ( eg. https://github.com/3box/3box-dapp/ )
  2. Add the following to the index.html:
    <script type="text/javascript">window.$crisp=[];window.CRISP_WEBSITE_ID="0d093f8e-b90c-49d2-a514-c3189145045a";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();</script>
  3. Run the website (eg npm start)
  4. Try to login to a Box or a Space and open the browser console. You will not be able to login, and you will see the error.
  5. Try remove crisp and there will be no error, and everything will work as it is supposed to.

Expected behavior 3box should be unaffected by adding 3rd party additions such as crisp. (there must be some kind of side effect in crisp that causes the problem?)

Tested on Firefox & chrome Ubuntu 19.04.

Additional context This isn't an issue with 3box but rather some internal dependencies of orbit-db and ultimately it calls: https://www.npmjs.com/package/is-circular and that returns false and throws the error.

I know this isn't probably a bug directly in 3box, but this is where the impact is. I hope someone in the team can bubble the issue up to where it can be fixed and that fix can be used downstream in 3box.

oed commented 4 years ago

Looks like is-circular is a dependency for some things that js-ipfs uses. I think you're right about crisp having some sort of side effect. Any insight into what it could be doing would be helpful!

JasoonS commented 4 years ago

Thanks for taking a look! Unfortunately I don't have any more insight. :(

I'm integrating 3box into v2 of https://wildcards.world , so hopefully we can find a solution before we want to launch (or I'll need to find another chat client).

oed commented 4 years ago

@JasoonS Do you know if the crisp client is open source? That would make things easier to debug. What timeline are you looking to release your v2 on?

Wildcards looks cool :)

JasoonS commented 4 years ago

Wildcards looks cool :)

Thanks :+1:

Doesn't seem like it is opensource :/ They have lots of code, but none of them seem to be the frontend integration: https://github.com/crisp-im

We will hopefully launch v2 in about a month. It is a pretty big redo, we replacing drizzle+truffle with thegraph.com and adding 3box and a few new features mostly enabled by thegraph.

I'll take a look at some alternatives such as https://www.chatwoot.com/ (free+opensource) anyway.