Skip to content

Commit

Permalink
docs(troubleshooting): add workarounds for code transpilation (#3399)
Browse files Browse the repository at this point in the history
References #1665
  • Loading branch information
cancerberoSgx authored and aslushnikov committed Oct 25, 2018
1 parent cf8c62e commit fae441c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/troubleshooting.md
Expand Up @@ -282,3 +282,15 @@ AWS Lambda [limits](https://docs.aws.amazon.com/lambda/latest/dg/limits.html) de
- https://github.com/adieuadieu/serverless-chrome/blob/master/docs/chrome.md (tracks the latest Chromium snapshots)
- https://github.com/universalbasket/aws-lambda-chrome
- https://github.com/Kikobeats/aws-lambda-chrome

## Code Transpilation Issues

If you are using a JavaScript transpiler like babel or TypeScript, calling `evaluate()` with an async function might not work. This is because while `puppeteer` uses `Function.prototype.toString()` to serialize functions while transpilers could be changing the output code in such a way it's incompatible with `puppeteer`.

Some workarounds to this problem would be to instruct the transpiler not to mess up with the code, for example, configure TypeScript to use latest ecma version (`"target": "es2018"`). Another workaround could be using string templates instead of functions:

```js
await page.evaluate(`(async() => {
console.log('1');
})()`);
```

0 comments on commit fae441c

Please sign in to comment.