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.

generators throws exception

See original GitHub issue

I try to use ES6 generators in a new clean ember-cli project but it doesn’t run in the browser because of Uncaught ReferenceError: regeneratorRuntime is not defined. It seems there is a missing global/dependency in my service?

function* testGenerator(fixtures) {
  for(let i = 0, max = fixtures.length; i < max; ++i) {
    yield foo(fixtures[i]);
  }
}

6to5 generates this source for my example:

var testGenerator = regeneratorRuntime.mark(function testGenerator(fixtures) {
  var i, max;
  return regeneratorRuntime.wrap(function testGenerator$(context$1$0) {
    while (1) switch (context$1$0.prev = context$1$0.next) {
      case 0:
        i = 0, max = fixtures.length;
      case 1:
        if (!(i < max)) {
          context$1$0.next = 7;
          break;
        }
        context$1$0.next = 4;
        return foo(fixtures[i]);
      case 4:
        ++i;
        context$1$0.next = 1;
        break;
      case 7:
      case "end":
        return context$1$0.stop();
    }
  }, testGenerator, this);
});

I’m using ember-cli@0.1.12 and ember-cli-6to5@3.0.0

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
ecengels88commented, Apr 5, 2017

For those who are running into this issue, see: https://github.com/babel/ember-cli-babel#polyfill

0reactions
ghostcommented, Jul 9, 2015

ok, thanks very much, I’ll try this. Just before you posted this, I was able to get my generator working by using the Bower package babel-polyfill and then including in the Brocfile:

app.import('bower_components/babel-polyfill/browser-polyfill.js', { prepend: true });

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Handle an exception thrown in a generator
When a generator throws an exception, it exits. You can't continue consuming the items it generates. Example:
Read more >
Generator.prototype.throw() - JavaScript - MDN Web Docs
The throw() method of a generator acts as if a throw statement is inserted in the generator's body at the current suspended position,...
Read more >
Generator::throw - Manual - PHP
Throws an exception into the generator and resumes execution of the generator. The behavior will be the same as if the current yield...
Read more >
PEP 288 – Generators Attributes and Exceptions
This PEP proposes to enhance generators by providing mechanisms for raising ... Add a .throw(exception) method to the generator interface:.
Read more >
Exception Handling and Generators in Python - ScholarBasta
Exception handling is a way of handling exceptions that occur during the runtime of the program and causes the program flow to terminate....
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