chimp: Node.js 7 and up does not show the error when an error occurs

The bug can be easily reproduced here(just clone and type npm start): https://github.com/capaj/chimp-cucumber-boilerplate/tree/showcase-awful-errorhandling

Expected behaviour
[chimp] Running...
Feature: Landing

  Scenario: It works
  ✖ When When I load up "facebook.com"
  - Then I should be able to select "Jan"

Failures:

1) Scenario: It works - features/landing.feature:3
   Step: When When I load up "facebook.com" - features/landing.feature:4
   Step Definition: features/step_definitions/landing.js:2
   Message:
     Error: unknown error: unhandled inspector error: {"code":-32000,"message":"Cannot navigate to invalid URL"}
         at World.<anonymous> (features/step_definitions/landing.js:3:13)

1 scenario (1 failed)
2 steps (1 failed, 1 skipped)
0m00.067s

Actual behaviour
Feature: Landing

  Scenario: It works
  ✖ When When I load up "facebook.com"
  - Then I should be able to select "Jan"

Failures:

1) Scenario: It works - features/landing.feature:3
   Step: When When I load up "facebook.com" - features/landing.feature:4
   Step Definition: features/step_definitions/landing.js:2
   Message:
     Error
         unknown error line

1 scenario (1 failed)
2 steps (1 failed, 1 skipped)
0m00.021s
Cucumber steps failed

Exact steps to reproduce / repository that demonstrates the problem

Please put long code snips in a Gist and provide a link here.

Version & tools:
  • Chimp: “^0.48.0”

  • Node.js: 7.8.0

  • Java: openjdk version “1.8.0_121” OpenJDK Runtime Environment (build 1.8.0_121-8u121-b13-4-b13) OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)

  • Operation system: ubuntu 17.04

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 19 (13 by maintainers)

Most upvoted comments

Alright,

I spent today digging around this, and I don’t have good news 😦

There are two issues,

First is caused by the change of how Errors construction is happening in node 7, basically, it used to be ok to extend error class, not pass anything to the parent constructor, and put whatever you wanted on this.type / this.message . https://github.com/webdriverio/webdriverio/blob/master/lib/utils/ErrorHandler.js#L5

This is no longer the case, in the end, if you want the log of the error to have a proper message, you need to pass it to the super() (so - instead of doing this.message = “wrong url” you do const message = “wrong url” and then super(message) ). When you look at the error.message, it’s still there, but it doesn’t show up in the actuall error log. Not fully understanding what’s going on I’ve recently hacked this to show errors in debug mode - https://github.com/webdriverio/webdriverio/commit/5b13166168a064adec45f8a25cb3f9d96af31544 , (sorry for that @christian-bromann , I will rever this and send a proper fix in the next few days). In the pictures posted above, I tried to do the same with cucumber, but then I realized, this is a bigger problem. So, with this fix in place, we will see “Error: unknown error: unhandled inspector error: {“code”:-32000,“message”:“Cannot navigate to invalid URL”}” instead of “Error”

Now, to the difficult part. Showing the line of the error.

Basically, the issue starts with node 7.0, out of the ~1600 commits that happened between a released 6.x version, and 7.0, I was able to pinpoint the issue to here:

screen shot 2017-08-26 at 21 37 45

With nodejs/node#8a24728 being the last “working” version, and nodejs/node#96933df being the first that compiles after the v8 5.4 update, and first not working.

The difference is in the way v8 started to showing a stack trace when running fiberized/asynced code. (it might be in the way we fiberize things in chimp, one thing to try is to see how this works with sync mode of wdio runner) Notice, with the 5.4 update, the first line, and the only we care about is missing screen shot 2017-08-26 at 17 48 16

Commit before, it’s there: screen shot 2017-08-26 at 17 47 57

The way webdriverio neatly produces custom errors, using the this.constructor argument here: Error.captureStackTrace(this, this.constructor) they remove the irrelevant to the user part of the stack trace. But, without the line we care about, we are left with nothing, and that’s why we see “unknown error line”.

unfortunately, the commit that brought the 5.4 update is massive ( 2,386 changed files with 260,277 additions and 148,300 deletions. ) and beyond my grasp at this moment.

Do you guys know of any nodejs magicians that could help us here?

I think the next step will be to work on preparing a much smaller example that would show the different stack traces, while not requiring running selenium/chromedriverio and loading the whole webdriverio, or chimp, to isolate the issue. I’m a bit hooked now, so I will most probably spend some time on this during the week, but I would appreciate any help!

I’m looking in this now

ok, once I posted this, thinking I’m done for today, I had a rather obvious idea… and got it…

screen shot 2017-08-22 at 20 45 28

I will do my best to release a version with a fix tomorrow. I need to check if I’m not breaking anything in the older versions.

This is inside cucumber v1 version btw, I’d be curious to see if this is just a universal problem with cucumber v1 (which is not really maintained anymore)

Yeah, righ… no. That’s exactly what I realized, and why haven’t pushed the fix yet. So… seems like this might be coming from webdriverio (and I’ve fixed a similar issue in that codebase recently). I have a few hours blocked today on that issue. Will update you guys with what I found.