Turning on Polly makes puppeteer do hundreds of requests
See original GitHub issueI am using jest + puppeteer to run tests. I am trying to use polly to record and serve requests to our API when running integration tests.
What happens when i turn on Polly to record our requests is that it starts running the same request for hundreds of times.
The packages I am using: PuppeteerAdapter, FSPersister. When I turn off Polly the request completes successfully.
I recorded a video of the chromium’s console: https://gfycat.com/EssentialShadowyAnura
Here are the versions I am using:
"@pollyjs/adapter-puppeteer": "^1.1.0",
"@pollyjs/core": "^1.1.0",
"@pollyjs/persister-fs": "^1.0.1",
and the configs:
Server
{
recordingsDir: path.join(__dirname, 'recordings'),
quiet: false,
port: 3001,
host: 'localhost'
}
Polly
{
adapters: ['puppeteer'],
adapterOptions: {
puppeteer: { page }
},
persister: 'fs',
persisterOptions: {
host: 'http://localhost:3001'
},
logging: true
}
Is there something I am missing in the config? Or in general?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
Block ressources with Puppeteer - ScrapingBee
In this article, we will take a look at how to block specific resources (HTTP requests, CSS, video, images) from loading in Puppeteer....
Read more >Web Scraping With a Headless Browser: Puppeteer - ScrapFly
As you can imagine, Puppeteer is a brilliant tool for web scraping! Automating a web browser gives our web scraper several advantages:.
Read more >Configure PollyJS to ignore some requests - Stack Overflow
I'm now trying to do an integration test where my jest code spins up a local server running on the ubiquitous 127.0.0.1:3000 and...
Read more >Useful tools: Headless Chrome & puppeteer for browser ...
When a site loads these files, it makes dozens of different asynchronous requests to complete the page with more information, in addition to...
Read more >MockRequest - CodeceptJS
This helper allows to mock requests while running tests in Puppeteer or WebDriver. For instance, you can block calls to 3rd-party services ...
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 Free
Top 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
Fixed with
@pollyjs/adapter-puppeteer@1.1.1
. @meikoudras thanks again for the reproduction, it was super helpful!Thank you for the quick fix!
I have updated the repo with another issue which seems to be related to CORS as well: https://github.com/meikoudras/jest-puppeteer-polly-test
The previous get request will work correctly but making a post request will again make the browser crash. I can make a separate issue for that as well, if that is required.
EDIT:
I think it is related to the handleRequest call here
When recording the initial response the preflight options request goes through here and makes puppeteer crash. When I fake a successful response to the options request everything works as expected.
So probably during a preflight request it should probably call:
And if the passthrough header is set it should fake the response.
Or is there a use case where a preflight requests response should be recorder in any way?