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.

Multiple clones not working

See original GitHub issue

This code fails in Safari 10.1 on El Capitan:

fetch('/').then(function(a) {
  var c1 = a.clone();
  var c2 = a.clone();

  c2.text().then(function(z) {
    console.log(z)
  }, function(x) {
    console.error(x)
  });
});

The promise log data never fulfills. Try running this code in Chrome directly on this issue page in console and then in Safari. Chrome – resolves, Safari – don’t.

Also it isn’t related which response is used in that situation, cloned or not. Just the matter of 2 clones prevents it from working.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
adamdillecommented, Feb 26, 2019

In case you, like me, run into a situation where you need to support multiple fetch response clones on Safari < 11, I discovered that once the response is cloned, the clone itself can be cloned any number of times without throwing “Cannot clone a disturbed Response”.

For example, the following fails because the response itself is cloned twice:

fetch('/').then(function(r) {
  try {
    r.clone().text().then(function(t) { console.log(t); }, function(e) { console.error(e) });
    r.clone().text().then(function(t) { console.log(t); }, function(e) { console.error(e) });
  } catch (e) {
    console.error(e);
  }
});

But cloning a clone twice succeeds:

fetch('/').then(function(r) {
  try { 
    var c = r.clone();
    c.clone().text().then(function(t) { console.log(t); }, function(e) { console.error(e) });
    c.clone().text().then(function(t) { console.log(t); }, function(e) { console.error(e) });
  } catch (e) {
    console.error(e);
  }
});
2reactions
domeniccommented, Dec 19, 2017

If someone wants to do a big service to the community, perhaps browse https://github.com/w3c/web-platform-tests/tree/master/fetch/api to see if this case is already tested, and if it’s not, add such a test. That will ensure it doesn’t regress in the future, in any browser.

Read more comments on GitHub >

github_iconTop Results From Across the Web

multiple clone not working when append in select 2
It is creating a clone of 'form-repaet' div but the select box is not working. I've tried select2(); after clone, but it is...
Read more >
Multiple clones of the same remote repo - Google Groups
I seem to have some problems pulling to the clone that hasn't been used for commits/pushes. On the other hand, the pull reports...
Read more >
How to Fix Clone App Not Working / Not Opening Problem in ...
CloneApp #NotOpen # NotWorking #ProblemIn this video Tutorial, i will show you How to Fix Clone App Not Working Problem in Android &...
Read more >
How To Fix Clone Apps Keeps Stopping Error Android & Ios
If you are facing same problem in your android mobile phone then it ... Clone app Clear cache and Clear Data If it...
Read more >
Cloning Multiple Issues - ALM Works Help Center
Select issues you'd like to clone using multiple selection. · Use Copy action on the toolbar (or hit Ctrl+C / Command+C) to copy...
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