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

No errors are thrown on asyncawait check. #3455

Closed
entrptaher opened this issue Oct 27, 2018 · 7 comments
Closed

No errors are thrown on asyncawait check. #3455

entrptaher opened this issue Oct 27, 2018 · 7 comments

Comments

@entrptaher
Copy link
Contributor

Origin of problem: puppeteer-web on chrome extension.
Source: https://github.com/GoogleChrome/puppeteer/blob/master/index.js#L21
Relevent Stackoverflow Question: https://stackoverflow.com/q/53001009/6161265

The bundled version shows anonymous function, figuring out the problem wasn't smooth.

image

Possible solutions:

  • It should notify the user somehow. Either by an argument or so in the browser.
  • Let the user know about possible gimmicks of trying this inside chrome extension, which is to let unsafe-eval on content_security_policy of their manifest.json file.
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
@aslushnikov aslushnikov mentioned this issue Nov 1, 2018
aslushnikov added a commit to aslushnikov/puppeteer that referenced this issue Nov 1, 2018
@aslushnikov
Copy link
Contributor

Thanks for letting us know. The lines you pointed to belong to our Node6 infrastructure. They will be removed once we drop Node6 support, and thus the necessity of unsafe-eval will go away as well.

As another workaround, you can build a custom version for puppeteer-web that doesn't pull in the index.js with this bifurcation for node6/node7.

@sigleane
Copy link

Hey guys, im having this error..
Someone knows how to solve it?

npm run bundle
npm ERR! missing script: bundle
npm ERR!
npm ERR! Did you mean this?
npm ERR! build

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users[...]

@jackyzhang69
Copy link

Hey guys, im having this error.. Someone knows how to solve it?

npm run bundle npm ERR! missing script: bundle npm ERR! npm ERR! Did you mean this? npm ERR! build

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users[...]

I have same issue. It seems that puppteer is not so popular in chrome extension. too less resources.

@yarekc
Copy link

yarekc commented Dec 17, 2021

Same issue:

npm run bundle
npm ERR! missing script: bundle
npm ERR!
npm ERR! Did you mean this?
npm ERR!     build

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-12-17T11_20_31_280Z-debug.log

@LuisMerinoP
Copy link

LuisMerinoP commented Feb 13, 2022

same error here.
I tried with this puppeteer-web script from this resurce but get this error:

WebSocket connection to 'ws://0.0.0.0:8080/' failed: (anonymous) @ puppeteer-web:13354

Is it possible then to run puppeteer on the browser?

@entrptaher
Copy link
Contributor Author

puppeteer has updated their ways of running and there are better alternatives. Just running the script won't get you far. Let me find another way and update my old answers. :D

@LuisMerinoP
Copy link

LuisMerinoP commented Feb 14, 2022

Thanks for your comment! I was talking regarding the npm run bundle command error concretely (not running the script).
As I could not have that done I tried this:

<script>
  const browser = await puppeteer.connect({
    browserWSEndpoint: `ws://0.0.0.0:8080, // <-- connect to a server running somewhere
    ignoreHTTPSErrors: true
  });

  const pagesCount = (await browser.pages()).length;
  const browserWSEndpoint = await browser.wsEndpoint();
  console.log({ browserWSEndpoint, pagesCount });
</script>

Previously setting a server like this:

const httpProxy = require("http-proxy");
const host = "0.0.0.0";
const port = 8080;

async function createServer(WSEndPoint, host, port) {
  await httpProxy
    .createServer({
      target: WSEndPoint, // where we are connecting
      ws: true,
      localAddress: host // where to bind the proxy
    })
    .listen(port); // which port the proxy should listen to
  return `ws://${host}:${port}`; // ie: ws://123.123.123.123:8080
}

const puppeteer = require("puppeteer");

puppeteer.launch().then(async browser=>{
  const pagesCount = (await browser.pages()).length; // just to make sure we have the same stuff on both place
  const browserWSEndpoint = await browser.wsEndpoint();
  const customWSEndpoint = await createServer(browserWSEndpoint, host, port); // create the server here
  console.log({ browserWSEndpoint, customWSEndpoint, pagesCount });
})

But did not succeed due to this error:

WebSocket connection to 'ws://0.0.0.0:8080/' failed: 
(anonymous) @ puppeteer-web:13354

I realize now that the answer where I got this code from in SO is also yours lol. I'll be thankful in case you have any comment to make this work :)

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

6 participants