paulmillr / es6-shim

ECMAScript 6 compatibility shims for legacy JS engines
http://paulmillr.com
MIT License
3.11k stars 387 forks source link

Unhandled exception at line 221 #364

Closed DeanB2015 closed 8 years ago

DeanB2015 commented 8 years ago

I have a test project using es6-shim (v0.33.6), Cordova 5.3.3 and Windows Phone (Universal).

I get the following error when I test on Windows Phone:

SCRIPT5007: Unhandled exception at line 221, column 7 in ms-appx-web://test/www/scripts/lib/es6-shim/es6-shim.js 
0x800a138f - JavaScript runtime error: Unable to get property 'toString' of undefined or null reference
es6-shim.js (221,7)

Cordova Mobile(Android) and Web(Chrome, IE, Firefox) are working well.

Here's the bare code I used to isolate es6-shim.

<!DOCTYPE html>
<html>
<head>
    <script src="scripts/es6-shim/es6-shim.js"></script>
</head>
<body>
    <p>Hello, your application is ready!</p>

</body>
</html>

Not sure if this is a problem with es6-shim or Cordova. Any help is greatly appreciated.

ljharb commented 8 years ago

@DeanB2015 Thanks for the report! it would help if you could provide a bit more of the stack trace - specifically, where preserveToString is being called inside es6-shim

fwiw, my Windows Phone tests work, so it might be a combination of Cordova and es6-shim causing this problem.

DeanB2015 commented 8 years ago

@ljharb

Call Stack

Value.preserveToString [es6-shim.js] Line 221   Script
    overrideNative [es6-shim.js] Line 270   Script
    Anonymous function [es6-shim.js] Line 3251  Script
    Anonymous function [es6-shim.js] Line 3240  Script
    Anonymous function [es6-shim.js] Line 25    Script
    Global code [es6-shim.js] Line 13   Script

Here's a screen shot from VS2015 Community vs_es6-shim

DeanB2015 commented 8 years ago

@ljharb Here's the Output > Debug:

'WWAHost.exe' (Script): Loaded 'Script Code (MSAppHost/3.0)'. 
Exception was thrown at line 140, column 7 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a138d - JavaScript runtime error: String.prototype.startsWith: 'this' is not a String object
Exception was thrown at line 1088, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a139e - JavaScript runtime error: Exception thrown and not caught
Exception was thrown at line 1088, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a139e - JavaScript runtime error: Exception thrown and not caught
Exception was thrown at line 1088, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a139e - JavaScript runtime error: Exception thrown and not caught
Exception was thrown at line 1088, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a139e - JavaScript runtime error: Exception thrown and not caught
Exception was thrown at line 1088, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a139e - JavaScript runtime error: Exception thrown and not caught
Exception was thrown at line 1088, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a139e - JavaScript runtime error: Exception thrown and not caught
Exception was thrown at line 1088, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a139e - JavaScript runtime error: Exception thrown and not caught
Exception was thrown at line 1266, column 7 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a138f - JavaScript runtime error: Invalid operand to 'Object.assign': Object expected
Exception was thrown at line 2189, column 7 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a13f8 - JavaScript runtime error: Promise: an unexpected failure occurred while trying to obtain metadata information
Exception was thrown at line 2192, column 66 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a13fc - JavaScript runtime error: Promise: 'this' is not a Promise object
Exception was thrown at line 2797, column 11 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a13fc - JavaScript runtime error: Map: 'this' is not a Map object
Exception was thrown at line 2827, column 11 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a13fc - JavaScript runtime error: Set: 'this' is not a Set object
Exception was thrown at line 39, column 7 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a13fc - JavaScript runtime error: Map: 'this' is not a Map object
Exception was thrown at line 39, column 7 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a13fc - JavaScript runtime error: Set: 'this' is not a Set object
Exception was thrown at line 3165, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a138a - JavaScript runtime error: Reflect.apply: argument is not a Function object
Exception was thrown at line 3165, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a138a - JavaScript runtime error: Reflect.construct: 'this' is not a Function object
Exception was thrown at line 3165, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a138f - JavaScript runtime error: Reflect.deleteProperty: argument is not an Object
Exception was thrown at line 3165, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a138f - JavaScript runtime error: Reflect.enumerate: argument is not an Object
Exception was thrown at line 3165, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a138f - JavaScript runtime error: Reflect.has: argument is not an Object
Exception was thrown at line 3165, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a138f - JavaScript runtime error: Reflect.ownKeys: argument is not an Object
Exception was thrown at line 3165, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a138f - JavaScript runtime error: Reflect.iesExtensible: argument is not an Object
Exception was thrown at line 3165, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a138f - JavaScript runtime error: Reflect.preventExtensions: argument is not an Object
Exception was thrown at line 3165, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a138f - JavaScript runtime error: Reflect.defineProperty: argument is not an Object
Exception was thrown at line 3165, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a138f - JavaScript runtime error: Reflect.getOwnPropertyDescriptor: argument is not an Object
Exception was thrown at line 3165, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a138f - JavaScript runtime error: Reflect.get: argument is not an Object
Exception was thrown at line 3165, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a138f - JavaScript runtime error: Reflect.set: argument is not an Object
Exception was thrown at line 3165, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a138f - JavaScript runtime error: Reflect.getPrototypeOf: argument is not an Object
Exception was thrown at line 3165, column 9 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a138f - JavaScript runtime error: Reflect.setPrototypeOf: argument is not an Object
Exception was thrown at line 3186, column 7 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a138f - JavaScript runtime error: Reflect.setPrototypeOf: argument is not an Object
Exception was thrown at line 3194, column 7 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a138f - JavaScript runtime error: Reflect.defineProperty: argument is not an Object
Unhandled exception at line 221, column 7 in ms-appx-web://testing/www/scripts/es6-shim/es6-shim.js
0x800a138f - JavaScript runtime error: Unable to get property 'toString' of undefined or null reference

Let me know if you need the code. I can add to github repository.

ljharb commented 8 years ago

wow - ok so all of the "exception thrown and not caught" errors actually happen inside a try/catch, so I'm not sure what's happening there. It's almost like all of those errors (except the first one) shouldn't be there, because a catch block should silence all of them.

Which version of es6-shim are you using? The line numbers don't match up to the latest version.

DeanB2015 commented 8 years ago

Just confirmed es6-shim: v0.33.6

ljharb commented 8 years ago

ok so this must be something about cordova. it's like every try/catch is being ignored.

I don't know how to possibly fix or debug this :-/

DeanB2015 commented 8 years ago

@ljharb Thanks again for the help. This helps me focus on where the problem could be located. I'll contact the Cordova team.

Windows Phone Universal appears to support es6. I think the solution to avoid errors is to not use es6 shims in Windows Phone Universal + Cordova.

Note: I just tried core-js shims and I'm getting similar JavaScript runtime errors

ljharb commented 8 years ago

There doesn't exist an engine that even the es5-shim isn't needed on - so you should be free to use shims if you want a reliable environment. Please do report back - I'd love to make sure the es6-shim can work for you.

DeanB2015 commented 8 years ago

@ljharb I created an issue on Apache Cordova's Issue tracking system.
https://issues.apache.org/jira/browse/CB-9838

I also added a stackoverflow question http://stackoverflow.com/questions/33256378/javascript-error-cordova-windows-phone-universal-es2015-shims

ljharb commented 8 years ago

Please reopen this if you hear back - I'm going to close for now.