Posts

Post not yet marked as solved
0 Replies
3.1k Views
"We have recently come across an error that exists only in Safari browser and impedes adoption of ES6.Essentially, attempting to access caller function property, which points to an async function, would result in a unahndled error.Here's a fiddle that demonstrates this issue: https://jsfiddle.net/ope31anx/1/Also here's a copy-paste of that code:MyClass = function() { var me = this; me.asyncFunc = async function() { me.syncFunc(arguments); alert('works!'); } me.syncFunc = function() { me.syncFunc.caller; // where error ocurrs in Safari } }; new MyClass().asyncFunc();Running this code in any browser other than Safari will result in "works!" alert. Running it in Safari will result in console error "Unhandled Promise Rejection: TypeError: Function.caller used to retrieve async function body".I can reproduce this in Safari 12.1.2.I can verify no such issue in Chrome 76.0.3809.132 or FireFox 69 or Edge 44.18362.329.0In our codebase this error is particularly annoying because since we use ExtJS and it uses similar approach for its callParent() implementation, which means we cannot use async/await because of Safari. My biggest surprise has been that I could not find a single entry on Google of anyone else facing this error. Perhaps it is recent.
Posted Last updated
.