question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Turning on Polly makes puppeteer do hundreds of requests

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
offirgolancommented, Aug 9, 2018

Fixed with @pollyjs/adapter-puppeteer@1.1.1. @meikoudras thanks again for the reproduction, it was super helpful!

0reactions
meikoudrascommented, Aug 9, 2018

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:

request.continue();

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found