ioBroker.admin icon indicating copy to clipboard operation
ioBroker.admin copied to clipboard

writeFile fails for bigger files with "too many arguments provided for a function call"

Open Garfonso opened this issue 4 years ago • 2 comments

Describe the bug
Lovelace UI calls socket.emit with arg1 = 'writeFile' and arg3 as ArrayBuffer for installation of custom cards and images. The type of arg3 is not string, which means that the the emit function tries to convert it here. This fails for quite small files, already smaller than one Megabyte. There are custom cards that are this big but also images reach the size easily.

To Reproduce
Steps to reproduce the behavior:

  1. Go to lovelace settings, custom cards tab
  2. Drag a file with ~1MB size into the browser
  3. See that UI hangs (this is a lovelace issue)
  4. See error in browser console

Expected behavior
The conversion should be altered so that String.fromCharCode is called in a loop or similar. This should prevent the "too many arguments provided for function call" error.

Screenshots & Logfiles
admin-too-many-arguments-for-a-function-call

Versions:

  • Adapter version: 5.1.25
  • JS-Controller version: 3.3.15
  • Node version: 12.20.1
  • Operating system: ubuntu / windows / firefox 90

Additional context
It seems that this issue is new with admin 5.

Garfonso avatar Aug 20 '21 12:08 Garfonso

@Garfonso Can this issue be closed (using Admin 6.x as well)?

Feuer-sturm avatar Jun 23 '22 20:06 Feuer-sturm

Actually, no. The exception still happens, if I revert my workaround (which is here https://github.com/ioBroker/ioBroker.lovelace/pull/251/files#diff-eb7e2d4606283f96380357fe1ea34b5f8d1907c3061a481f0ce9360221c00944L279 ). Instance settings are then in an undefined state and not working (till F5 is pressed) and the file is not uploaded successfully.

With the workaround, the upload works fine. My suggestion would be to "move" my workaround to the socket.io.js file.

Garfonso avatar Jun 24 '22 16:06 Garfonso

Please test with 6.2.16

GermanBluefox avatar Aug 18 '22 18:08 GermanBluefox

works now. Thanks. :-)

Garfonso avatar Aug 19 '22 08:08 Garfonso