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

Program is crashing in production only w/ invalidDid #1251

Closed
dysbulic opened this issue Apr 14, 2021 · 6 comments
Closed

Program is crashing in production only w/ invalidDid #1251

dysbulic opened this issue Apr 14, 2021 · 6 comments

Comments

@dysbulic
Copy link
Contributor

dysbulic commented Apr 14, 2021

Bug Description

When the button is clicked on https://dysbulic.github.io/xml-to-ipld/#/ceramic the application crashes with the following error:

Uncaught (in promise) Error: Failed to resolve did:3:kjzl6cwe1jw14936apxr6lxhewn3srcpxjwjtu777mkfio7718ue8alc7pfr717?version-id=0#pn1iiYhhzD3kUev: invalidDid, TypeError: Cannot call a class as a function
    at A.<anonymous> (index.ts:303)
    at c (runtime.js:63)

The value of DID before the error is:

Screenshot from 2021-04-14 01-49-05

This issue does not occur in development. In development, the value of DID at the same location is:

Screenshot from 2021-04-14 01-49-41

The code being run is:

  const connect = async () => {
    
    const ceramic = (
      new Ceramic('https://ceramic-clay.3boxlabs.com')
    )
    await ceramic.setDIDProvider(didProvider)
    setCeramic(ceramic)
  }

Then in @ceramicnetwork/http-client:

  async setDIDProvider(provider: DIDProvider): Promise<void> {
    this.context.provider = provider;
    this.context.did = new DID({ provider, resolver: this.context.resolver })
    if (!this.context.did.authenticated) {
      await this.context.did.authenticate()
    }
  }

It dies calling new DID().

To Reproduce

  1. Go to https://dysbulic.github.io/xml-to-ipld/#/ceramic.
  2. Click on the "Connect Your Wallet" button.
  3. View the error in the console.
  4. git clone https://github.com/dysbulic/xml-to-ipld.git
  5. cd xml-to-ipld && yarn && yarn start
  6. No error and the program completes satisfactorily.

Expected Behavior

I would like the behavior in production to be the same as development.

Ceramic Versions

  • @ceramicnetwork/3id-did-resolver@^1.1.1
  • @ceramicnetwork/common@^0.17.0
  • @ceramicnetwork/docid@^0.5.1
  • @ceramicnetwork/doctype-caip10-link@^0.13.4
  • @ceramicnetwork/doctype-tile@^0.14.1
  • @ceramicnetwork/http-client@^0.10.1
  • @ceramicstudio/idx@^0.7.0
  • @ceramicstudio/[email protected]

Machine, OS, Browser Information

  • Linux fenrir 5.8.0-48-generic #54~20.04.1-Ubuntu SMP Sat Mar 20 13:40:25 UTC 2021 x86_64 GNU/Linux
  • Browsers:
    • Chrome 89.0: Works in development, not in production.
    • Firefox 87.0: Works in development, not in production.
    • Opera: Crashes b/c accounts[0] is not defined.
    • Brave: Crashes b/c window.ethereum is not defined.

Additional Information

It looks to me like the minimizer made a mistake, but that just seems so unlikely.

@oed
Copy link
Member

oed commented Apr 14, 2021

That's quite strange. What's the difference between your production and your develop environments?

@dysbulic
Copy link
Contributor Author

What's the difference between your production and your develop environments?

Now that you mention it, I was trying to use loadable components and webpack to do authorized cross-site scripting.

I'm pretty sure something I did there has borked webpack. I'll investigate.

Thanks.

@Geo25rey
Copy link
Contributor

@dysbulic Did you every figure this out? I am having a similar problem using create-react-app.

@dysbulic
Copy link
Contributor Author

@Geo25rey, I've not yet figured it out. I tried pulling out everything custom I did to Webpack, removing node_modules/ (then yarn.lock), and now I'm getting an error that TextDecoder is not defined. It should be built in to the browser.

I've honestly not been working on it much because it works locally, so I can run my tests. I just can't share them w/ anyone.

@Geo25rey
Copy link
Contributor

@Geo25rey, I've not yet figured it out. I tried pulling out everything custom I did to Webpack, removing node_modules/ (then yarn.lock), and now I'm getting an error that TextDecoder is not defined. It should be built in to the browser.

Run npm install --save --exact-version [email protected], I had the same issue recently.

@Geo25rey
Copy link
Contributor

@dysbulic Check this out

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

3 participants