Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Zone.js Does not support creating Error objects without new oberator #555

Closed
KrauseStefan opened this issue Dec 20, 2016 · 4 comments
Closed

Comments

@KrauseStefan
Copy link

When running protractor with angular2 Dependency injection and therefore using zone.js I get the following error:

 Error: TypeError: Cannot set property 'message' of undefined
    at ZoneAwareError (project\node_modules\zone.js\dist\zone-node.js:683:22)
    at captureStackTrace (project\node_modules\selenium-webdriver\lib\promise.js:691:11)
    at new Task (project\node_modules\selenium-webdriver\lib\promise.js:2662:29)
    at ControlFlow.execute (project\node_modules\selenium-webdriver\lib\promise.js:2246:16)
    at Function.createSession (project\node_modules\selenium-webdriver\lib\webdriver.js:329:24)
    at Builder.build (project\node_modules\selenium-webdriver\builder.js:458:24)
    at Local.DriverProvider.getNewDriver (project\node_modules\protractor\built\driverProviders\driverProvider.js:37:33)
    at Runner.createBrowser (project\node_modules\protractor\built\runner.js:197:43)
    at project\node_modules\protractor\built\runner.js:276:30
    at _fulfilled (project\node_modules\q\q.js:834:54)
    at self.promiseDispatch.done (project\node_modules\q\q.js:863:30)
    at Promise.promise.promiseDispatch (project\node_modules\q\q.js:796:13)
    at project\node_modules\q\q.js:604:44
    at runSingle (project\node_modules\q\q.js:137:13)
    at flush (project\node_modules\q\q.js:125:13)

The line producing errors in zone.js:

let error: Error = NativeError.apply(this, arguments);

Example of a place where Error is called without new: https://github.com/SeleniumHQ/selenium/blob/ba56ad1ae0b98a1fe1efdd2163c62fc847950178/javascript/node/selenium-webdriver/lib/promise.js#L714

We can agree that it would be best practice to use new, but I think zone.js if it forces wrapping the Error class should work the same way.

@JiaLiPassion
Copy link
Collaborator

I think it is my mistake, I didn't return this in PR #547, I'll make a PR now.

JiaLiPassion added a commit to JiaLiPassion/zone.js that referenced this issue Dec 20, 2016
…structor, and copy native error's properties
@KrauseStefan
Copy link
Author

KrauseStefan commented Dec 20, 2016

I was trying to fix this as well, it seems that the issue does not reproduce normally in the test environment.
Apparently "use strict"; is not applied there.
This defect does not reproduce unless it is there.
Have a look at my commit here: KrauseStefan@f867d2d
In the commit I've commented out one solution for the problem. It has been tested to also work in my build env.

I believe instead of using .apply(undefined, []) you could also use setTimeout to get a more realistic version, however there is no point in introducing asynchronous tests.

I'm not sure how you would like to fix the issue that test env does not reflect runtime env in regard to 'use strict'. I guess it needs to fit into a bigger puzzle with the distribution.

@JiaLiPassion
Copy link
Collaborator

@KrauseStefan , yeah, without use strict, this will be global, and with use strict, this will become undefined. I just try to add some logic to deal with it.

@KrauseStefan
Copy link
Author

This is fixed long ago, I will close.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants