try-puppeteer icon indicating copy to clipboard operation
try-puppeteer copied to clipboard

try-puppeteer: (async() => { ... })() fails silently

Open ebidel opened this issue 7 years ago • 2 comments

From @ithinkihaveacat on November 2, 2017 12:33

The following code (abbreviated version of a file from the examples folder) fails silently when entered in the editing component at https://try-puppeteer.appspot.com/:

(async() => {
const browser = await puppeteer.launch();
console.log('Hello, World');
})();

Actual:

No output, no error message.

Expected:

The output Hello, World!.

Copied from original issue: GoogleChrome/puppeteer#1254

ebidel avatar Nov 02 '17 15:11 ebidel

Ironically, this by itself works:

(async() => {
console.log('Hello, World');
})();

I think we can get around it by adding an await in front of the user code (https://github.com/ebidel/try-puppeteer/blob/master/backend/server.js#L85) just in case someone uses an async IIFE wrapper.

ebidel avatar Nov 02 '17 18:11 ebidel

Unfortunately, that won't work if the user just has:

const browser = await puppeteer.launch();
...

ebidel avatar Nov 02 '17 18:11 ebidel