3

I am trying to work with an ArrayBuffer object in a lightning component. This ArrayBuffer is being created from a url via a third party library (JSZip). This is working, but with LockerService active, rather than an ArrayBuffer I get a Proxy with the properties Proxy {$actual$: ArrayBuffer}. If I then go to use this to create a DataView for example by calling new DataView(myBuffer), I get

Uncaught TypeError: First argument to DataView constructor must be an ArrayBuffer

Is there any supported way to pull the actual ArrayBuffer object out of that Proxy so that I can work with it?

Update for XHR

I am adding a few more details on this. It appears I can use an ArrayBuffer if I am constructing it myself, but when trying to get it from XMLHttpRequest.response I am getting back a Proxy. Is there a different LockerService friendly way I can get the direct ArrayBuffer out of the response without it being set up as a Proxy?

  • This was fixed in Winter 17 release that is making its way to all instances currently. I assume you are on an instance that is running Summer 17. If that is not the case, we will investigate. – Ravi Jayaramappa Oct 10 '17 at 19:44
2

It's not possible currently. The proxy is part of the security mechanism that was implemented.

  • Does this mean that ArrayBuffer is simply not supported? It is listed in the compatibility table (documentation.auraframework.org/lockerApiTest/…) but if it cannot be passed as an argument to any of the other constructors/functions that consume it then all I would be able to do was see the length of the buffer. – dsharrison Oct 6 '17 at 19:43
  • @dsharrison, ArrayBuffer is supported since you can do `new ArrayBuffer()". However, there are issues around proxies, in particular when a proxy is send to a method or a constructor, as in your case. I need to discuss with the implementer to understand why we need to wrap that specific type. – JF Paradis Oct 10 '17 at 17:50
  • Thanks for the update. I added a small note to my question that explains that I am pulling the ArrayBuffer out of an XMLHttpRequest reaponse. It looks like the framework is converting both ArrayBuffer and Blob response types too Proxy, which is where my issue is coming from. – dsharrison Oct 10 '17 at 18:01
  • @dsharrison, could you provide me with the AuraJarVersion that are you using? Can you check this link on your instance? /sfdc/releaseVersion.jsp – JF Paradis Oct 10 '17 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.