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

Uncaught ReferenceError: o is not defined #3

Closed
ericleponner opened this issue Jan 9, 2023 · 3 comments
Closed

Uncaught ReferenceError: o is not defined #3

ericleponner opened this issue Jan 9, 2023 · 3 comments
Assignees

Comments

@ericleponner
Copy link

I'm using browser-solidity-compiler from a VueJS application.

When I run on my local dev environment, everything works fine : solidityCompiler() loads and runs the compiler perfectly.

However when I deploy my VueJS app on an production host, solidityCompiler() throws the following error in navigator console:

Uncaught ReferenceError: o is not defined

Have you ever face this kind of issue ?
Thanks for any help

@ericleponner
Copy link
Author

After investigations, it looks like component is crashing on browser.solidity.worker.ts line 15.

I see that importScripts() is kind of stub : it seems to be ok with vuejs dev environment but not in production. Do I need to provide some code here ?

function browserSolidityCompiler() {
  const ctx: Worker = self as any;

  ctx.addEventListener('message', ({ data }) => {
    if (data === 'fetch-compiler-versions') {
      fetch('https://binaries.soliditylang.org/bin/list.json').then(response => response.json()).then(result => {
        postMessage(result)
      })
    } else {
      importScripts(data.version);            <=== HERE
      const soljson = ctx.Module;

      if ('_solidity_compile' in soljson) {
        const compile = soljson.cwrap('solidity_compile', 'string', ['string', 'number']);
        const output = JSON.parse(compile(data.input))
        postMessage(output)
      }
    }
  });
}

function importScripts(_arg0: string) {
  throw new Error('Function not implemented.'); 
}

@rexdavinci rexdavinci self-assigned this Jan 12, 2023
@rexdavinci
Copy link
Owner

Please refer to vuejs dev tools issue#514

@ericleponner
Copy link
Author

I did not find root cause of the issue.
I worked around by writing my own worker using plain javascript.
Thanks for helping.

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