Can't pass function to evaluationContext (Improvement?)
See original GitHub issueSteps to reproduce
Tell us about your environment:
- Puppeteer version: “^0.12.0”
- Platform / OS version: Windows
- URLs (if applicable): https://github.com/Vandivier/data-science-practice/tree/function-to-evaluation-context-repro
What steps will reproduce the problem?
Please include code that reproduces the issue.
see https://github.com/Vandivier/data-science-practice/tree/function-to-evaluation-context-repro
clone and execute npm run-script get-riders
What is the expected result?
Objects will be printed to console which contain the key-value pair ‘hi’, ‘sup’, as well as a key ‘fpEvaluateInPage’ with a function as the value. Additionally, this function should be executed, printing ‘hi’ to the console on it’s own line.
What happens instead? Objects are printed to console only containing the key-value pair ‘hi’, ‘sup’
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How can I pass variable into an evaluate function?
For pass a function , there are two ways you can do it. // 1. Defined in evaluationContext await page.evaluate(() => { window....
Read more >StartResourceEvaluation - AWS Config
Runs an on-demand evaluation for the specified resource to determine whether the resource details will comply with configured AWS Config rules.
Read more >Advanced features — Cottle Documentation 2.0.0 ...
The callback you'll pass to Function takes multiple arguments: First argument is always an internal state that must be forwarded to any nested...
Read more >How to execute Context, Input, Process, and Product ... - NCBI
Improvements to education are necessary in order to keep up with the education ... the evaluation method itself cannot assume the role of...
Read more >7 Environments | Advanced R - Hadley Wickham
How do you determine the environment from which a function was called? How are <- and <<- different? ... We can't go any...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Vandivier if I understand correctly, you’re passing function from node.js context over to the page context as one of the arguments in the
page.evaluate
:This won’t work since
myObject
, and specifically function inside it, is not Serializable. To pass function over to the page context, you’ll have to stringify it first and then re-create in browser:lol. Since when is “I can’t understand” a reason to close an issue?
Here’s the issue in it’s simplest form. Consider the following object:
If this object is passed as options to evaluationContext, options.hi exists and options.fpEvaluateInPage does not exist. Or at very least the
console.log('hi')
fails to print in combination with_page.on('console', _fCleanLog);
, where _fCleanLog is defined as follows: