ioBroker.admin
ioBroker.admin copied to clipboard
writeFile fails for bigger files with "too many arguments provided for a function call"
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:
- Go to lovelace settings, custom cards tab
- Drag a file with ~1MB size into the browser
- See that UI hangs (this is a lovelace issue)
- 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
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 Can this issue be closed (using Admin 6.x as well)?
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.
Please test with 6.2.16
works now. Thanks. :-)