Open bagnus opened 4 years ago
Hello bagnus,
Don't know if you're still facing this issue. I had a similar problem with filepond (uncaught exception (in promise) that stops my JavaScript) when I tried to upload a file larger than the server limit. In my case it was a 503 error.
After hours of debugging, I found that the culprit was a missing "catch" on the following promise function in filepond.js :
var processFile = function processFile(query) { return new Promise(function(resolve, reject) { store.dispatch('REQUEST_ITEM_PROCESSING', { query: query, success: function success(item) { resolve(item); }, failure: function failure(error) { reject(error); } }); }); };
Maybe it's not the most efficient solution but, again in my case, adding a "catch" resolves my problem :
var processFile = function processFile(query) { return new Promise(function(resolve, reject) { store.dispatch('REQUEST_ITEM_PROCESSING', { query: query, success: function success(item) { resolve(item); }, failure: function failure(error) { reject(error); } }); }).catch(function(e) { console.log('file error', e); console.log('file name', e.file.filename); console.log('file id', e.file.id); }); };
Hope this will help...
Hi, thanks for your update. In the next weeks I’ll try your solution. Greetings Andrea
Il giorno 22 gen 2021, alle ore 12:20, ludoklein notifications@github.com ha scritto:
Hello bagnus,
Don't know if you're still facing this issue. I had a similar problem with filepond (uncaught exception (in promise) that stops my JavaScript) when I tried to upload a file larger than the server limit. In my case it was a 503 error.
After hours of debugging, I found that the culprit was a missing "catch" on the following promise function in filepond.js :
var processFile = function processFile(query) { return new Promise(function(resolve, reject) { store.dispatch('REQUEST_ITEM_PROCESSING', { query: query, success: function success(item) { resolve(item); }, failure: function failure(error) { reject(error); } }); }); };
Maybe it's not the most efficient solution but, again in my case, adding a "catch" resolves my problem :
var processFile = function processFile(query) { return new Promise(function(resolve, reject) { store.dispatch('REQUEST_ITEM_PROCESSING', { query: query, success: function success(item) { resolve(item); }, failure: function failure(error) { reject(error); } }); }).catch(function(e) { console.log('file error', e); console.log('file name', e.file.filename); console.log('file id', e.file.id); }); };
Hope this will help...
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pqina/filepond/issues/525#issuecomment-765333588, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEJWBTIS5CEOTBVHGBPHXTTS3FNPXANCNFSM4OD55Q3Q.
@ludoklein: Just tested and it worked well. No more Javascript error that stopped the client execution. By the way, when server returns http 400 or 500 codes there is no way to pass back a string error so I used a dedicated cookie to setup error string in server before return. The client, reading the same cookie, is able to display the error if present. Greetings Andrea
@ludoklein: if you agree, you can incorporate the catch(function(e)... in function processFile() Greetings Andrea
Hi, trying to test for server errors during file store at end of upload. I use PHP Filepond Uploader server with my own file save PHP procedure. Any exception thrown into one of PHP methods is converted (by handle_server_exceptions()) into http 500 error (this is expected).
Everything works (ex: the graphic file thumbnail get red color and the user is allowed to try again), but I obtain also a Javascript Uncaught exception (in promise) error that stops JS.
Error happens only with http 500 (or 400) error from server. If there is no error, everything is OK.
Don't really know if it's a bug, it could be my code fault...
Logs
Log is from Chrome console.
To Reproduce
My setup:
To get the error, throw any exception in PHP saveFile methods
Expected behavior In browser graphic user interface there are no problems, but JS is stopped after unchaught error.
Information about your project: Problem tested on Mac OSX 10.14 and Windows 7 and both browsers Firefox 77.01 and Chrome 83.0.
Tested with filepond.js 4.17.1
Additional context