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.

err-saga.js causes problems when syntax errors are caught

See original GitHub issue

When a syntax error is caught, err-saga.js gets as far as line 5 and stops all processes.

There is a syntax error message in the dev console

There is no error toast

I can’t see anything in ~ /client/commonFramwork/ working eg. code-storage, detect-unsafe-code-stream, display-test-results` etc…

anim

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
utsabcommented, Oct 14, 2016

I’d like to take on this bug.

0reactions
Bounceycommented, Oct 26, 2016

I have just pulled the latest staging and tried this out again.

Running tests with an unfinished function declaration in the code causes the error toast, but nothing happens after that.

Output remains at // running test

The test-suite switches and remains in its initial state

There is no error message in output

It looks like throwers() is throwing the Error object correctly,

Error: SyntaxError: Unsafe or unfinished function declaration
    at Object.checkForUnfinishedFunction [as thrower] (http://localhost:3000/js/bundle.js:122177:16)
    at http://localhost:3000/js/bundle.js:122204:51
    at tryCatcher (http://localhost:3000/js/bundle.js:2943:32)
    at InnerObserver.Rx.FlatMapObservable.InnerObserver.next (http://localhost:3000/js/bundle.js:5020:44)
    at InnerObserver.Rx.internals.AbstractObserver.AbstractObserver.onNext (http://localhost:3000/js/bundle.js:4642:32)
    at InnerObserver.tryCatcher (http://localhost:3000/js/bundle.js:2943:32)
    at AutoDetachObserverPrototype.next (http://localhost:3000/js/bundle.js:14690:52)
    at AutoDetachObserver.Rx.internals.AbstractObserver.AbstractObserver.onNext (http://localhost:3000/js/bundle.js:4642:32)
    at loopRecursive (http://localhost:3000/js/bundle.js:5507:12)
    at scheduleWork [as action] (http://localhost:3000/js/bundle.js:3949:12)
    at ScheduledItem.invokeCore (http://localhost:3000/js/bundle.js:3860:34)
    at ScheduledItem.invoke (http://localhost:3000/js/bundle.js:3848:41)
    at runTrampoline (http://localhost:3000/js/bundle.js:4089:38)
    at tryCatcher (http://localhost:3000/js/bundle.js:2943:32)
    at CurrentThreadScheduler.schedule (http://localhost:3000/js/bundle.js:4105:46)
    at CatchObservable.Rx.ObservableBase.ObservableBase._subscribe (http://localhost:3000/js/bundle.js:4975:33)

but this error never makes it to the console. In it’s place is an Error thrown by Parser.pp.raise:

SyntaxError: unknown: Unexpected token (11:8)
   9 | b = b - 15;
  10 | c = c - 1;
> 11 | function
     |         ^
    at Parser.pp.raise (http://localhost:3000/js/bundle.js:89558:14)
    at Parser.pp.unexpected (http://localhost:3000/js/bundle.js:91165:9)
    at Parser.pp.parseFunction (http://localhost:3000/js/bundle.js:90586:11)
    at Parser.pp.parseFunctionStatement (http://localhost:3000/js/bundle.js:90263:16)
    at Parser.pp.parseStatement (http://localhost:3000/js/bundle.js:90051:20)
    at Parser.parseStatement (http://localhost:3000/js/bundle.js:91199:23)
    at Parser.pp.parseBlockBody (http://localhost:3000/js/bundle.js:90476:22)
    at Parser.pp.parseTopLevel (http://localhost:3000/js/bundle.js:89990:9)
    at Parser.parse (http://localhost:3000/js/bundle.js:18950:18)
    at parse (http://localhost:3000/js/bundle.js:35207:48)
    at File.parse (http://localhost:3000/js/bundle.js:24638:16)
    at File.parseCode (http://localhost:3000/js/bundle.js:24723:21)
    at http://localhost:3000/js/bundle.js:73653:13
    at File.wrap (http://localhost:3000/js/bundle.js:24685:17)
    at Pipeline.transform (http://localhost:3000/js/bundle.js:73651:18)
    at Object.babelTransformer [as transformer] (http://localhost:3000/js/bundle.js:122299:27)

This is parser.pp.raise:

/* 737 */
/***/ function(module, exports, __webpack_require__) {

    "use strict";

    var _location = __webpack_require__(172);

    var _index = __webpack_require__(57);

    var _index2 = _interopRequireDefault(_index);

    function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

    var pp = _index2.default.prototype;

    // This function is used to raise exceptions on parse errors. It
    // takes an offset integer (into the current `input`) to indicate
    // the location of the error, attaches the position to the end
    // of the error message, and then raises a `SyntaxError` with that
    // message.

    pp.raise = function (pos, message) {
      var loc = (0, _location.getLineInfo)(this.input, pos);
      message += " (" + loc.line + ":" + loc.column + ")";
      var err = new SyntaxError(message);
      err.pos = pos;
      err.loc = loc;
      throw err;
    };

/***/ },

This part of webpack is overriding the Error object from throwers

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can syntax errors be caught in JavaScript? - Stack Overflow
You cannot use try-catch blocks to handle syntax errors as they are thrown while the code is being parsed and not while it's...
Read more >
SyntaxError - JavaScript - MDN Web Docs
The SyntaxError object represents an error when trying to interpret syntactically invalid code. It is thrown when the JavaScript engine encounters tokens or ......
Read more >
How to Handle the Syntax Error in Javascript - Rollbar
The Javascript SyntaxError is caused by the incorrect use of a pre-defined syntax. Syntax errors are detected while interpreting or parsing ...
Read more >
JavaScript Syntax Errors and How to Prevent Them - Meticulous
The following are some examples of syntax errors that commonly cause trouble for developers. Missing or Unmatched Quotation Marks. Quotation ...
Read more >
JavaScript Beginners - Know How To Solve Your Syntax Errors
In this tutorial, we're going to take a look at syntax errors in JavaScript and how to solve syntax errors in JavaScript if...
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