Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XMLHttpRequest response type cannot be changed for synchronous requests #356

Closed
ghost opened this issue Aug 20, 2020 · 0 comments · Fixed by #363
Closed

XMLHttpRequest response type cannot be changed for synchronous requests #356

ghost opened this issue Aug 20, 2020 · 0 comments · Fixed by #363
Labels
bug 🐞 Something isn't working 📦 adapter-xhr

Comments

@ghost
Copy link

ghost commented Aug 20, 2020

Prerequisites

ubuntu 16.04
node 12.16.3
cypress: 4.11.0
pollyjs: 5.0.0

Description

Project using google maps, during tests polly intercepting request to https://map.googleapis.com and seems want to set
its responseType, but since this is syncrhonous request browser throws error.

Tried to use client side server to passtrhough all requests to map.googleapis.com but it is not helping. In the end run polly
in passthrough mode, but even in this case get same error.

Shareable Source

I setup polly in index.js, root file for react application (testname set from cypress test code):

if (window.Cypress) {
  Polly.register(XMLHttpAdapter);
  Polly.register(RESTPersister);
  window.polly = new Polly(window.testName, {
    adapter: ['xhr'],
    persister: 'rest',
    mode: 'passthrough',
  })
}

Error Message & Stack Trace

DOMException: Failed to set the 'responseType'
property on 'XMLHttpRequest': The response type cannot be changed for
synchronous requests made from a document
  at XHRAdapter_callee$

Config

new Polly('Recording Name', {
    adapter: ['xhr'],
    persister: 'rest',
    mode: 'passthrough',
});

Dependencies

Copy the @pollyjs dependencies from package.json:

{
  "@pollyjs/core": "5.0.0",
  "@pollyjs/adapter-xhr": "5.0.0",
  "@pollyjs/persister-rest": "5.0.0"
}

Relevant Links

Environment

Tell us which operating system you are using, as well as which versions of Node.js and npm/yarn. If applicable, include the browser and the corresponding version.

Run the following to get it quickly:

linux ubuntu 16.04
npm 6.14.4
node 12.16.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working 📦 adapter-xhr
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants