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.

Puppeteer adapter + Rest persister does not work.

See original GitHub issue

The problem is that global.XMLHttpRequest which rest persister uses is not defined. I have tried adding xhr adapter, jus to see if it will make a difference, but I got [Polly] [adapter:xhr] XHR global not found because I use puppeteer

options

{
      adapters: ['puppeteer'],
      persister: 'rest',
      adapterOptions: {
        puppeteer: { page },
      },
      persisterOptions: {
        rest: {
          host: 'http://localhost:8080',
        },
      },
}

error

TypeError: NativeXMLHttpRequest is not a constructor

      at _Promise (node_modules/@pollyjs/persister-rest/dist/cjs/pollyjs-persister-rest.js:1289:17)
      at new F (node_modules/@pollyjs/persister-rest/dist/cjs/pollyjs-persister-rest.js:210:28)
      at ajax (node_modules/@pollyjs/persister-rest/dist/cjs/pollyjs-persister-rest.js:1288:10)
      at RestPersister.ajax (node_modules/@pollyjs/persister-rest/dist/cjs/pollyjs-persister-rest.js:1345:12)
      at node_modules/@pollyjs/persister-rest/dist/cjs/pollyjs-persister-rest.js:1352:36
      at step (node_modules/@pollyjs/persister-rest/dist/cjs/pollyjs-persister-rest.js:1227:30)
      at node_modules/@pollyjs/persister-rest/dist/cjs/pollyjs-persister-rest.js:1245:14

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
offirgolancommented, Jul 30, 2018

@harunurhan the REST Persister is meant to be used from within a browser. Since you’re running Puppeteer in Node, I would suggest using the FS Persister instead.

1reaction
offirgolancommented, Jul 31, 2018

@harunurhan can you bump all your @pollyjs packages to their latest versions? That should resolve the issue you’re running into.

Read more comments on GitHub >

github_iconTop Results From Across the Web

@pollyjs/persister-rest v6.0.5 Bundlephobia
Size of @pollyjs/persister-rest v6.0.5 is 142.1 kB (minified), and 43.3 kB when compressed using GZIP. Bundlephobia helps you find the performance impact of ......
Read more >
pollyjs__core JavaScript and Node.js code examples - Tabnine
describe('Unit | Puppeteer Adapter', function() { setupPolly(); ... Can be overridden at runtime in cases where the * Polly server is externally hosted....
Read more >
@pollyjs/adapter-puppeteer - npm
Start using @pollyjs/adapter-puppeteer in your project by running `npm i @pollyjs/adapter-puppeteer`. There are 3 other projects in the npm ...
Read more >
How to use the @pollyjs/core.Polly function in @pollyjs/core | Snyk
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >
https://raw.githubusercontent.com/Netflix/pollyjs/...
... (2021-12-07) ### Bug Fixes * **core:** Fix types for registering adapters and persisters ([#435](https://github.com/netflix/pollyjs/issues/435)) ...
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