-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
If there is an error during init, there is no event thrown so the error can't be caught in the callback.
uploadId = self.crypto.randomUUID();
var payload = {
id: uploadId,
filePath: fileUri,
fileKey: "file",
serverUrl: serverUri,
notificationTitle: "Uploading videos",
headers: {},
parameters: {}
};
uploader = FileTransferManager.init({}, function (event) {
if (event.state == 'UPLOADED') {
console.log("video uploader - upload complete"+ JSON.stringify(event));
}
else if (event.state == 'FAILED') {
if (event.id) {
console.log("video uploader - "+ event.id + " has failed "+ event.error);
}
else {
console.log("video uploader caught an error: " + event.error);
}
}
else if (event.state == 'UPLOADING') {
console.log("video uploader - " + event.id + " progress: " + event.progress + "%");
}
});
uploader.startUpload(payload);
There is an error accessing the file defined in the payload object, resulting in an error - but there is no way to catch the error so it can be handled.
2023-10-06 07:57:00.207 11546-11546 chromium com.appname I [INFO:CONSOLE(152)] "20231006075700: videos.html: uploadEventVideo(): starting video file upload
", source: file:///android_asset/www/shared/scripts/shared.js (152)
2023-10-06 07:57:00.232 11546-11546 chromium com.appname I [INFO:CONSOLE(152)] "20231006075700: videos.html: prepareUpload(): background transfer payload {"id":"71f3e9ea-6977-423a-ae5c-ce3fe2bb4e65","filePath":"file:///sdcard/.transforms/synthetic/picker/0/com.android.providers.media.photopicker/media/1000006860.mp4","fileKey":"file","serverUrl":"https://example.net/send_backgroundFile.php","notificationTitle":"Uploading videos","headers":{},"parameters":{}}
", source: file:///android_asset/www/shared/scripts/shared.js (152)
2023-10-06 07:57:00.232 11546-11546 chromium com.appname I [INFO:CONSOLE(152)] "20231006075700: videos.html: prepareUpload(): background transfer init start
", source: file:///android_asset/www/shared/scripts/shared.js (152)
2023-10-06 07:57:00.240 11546-11799 PluginManager com.appname D getPlugin - put: FileTransferBackground
2023-10-06 07:57:00.273 11546-11838 CordovaBackgroundUpload com.appname D startUpload: Starting worker via work manager
2023-10-06 07:57:00.280 11546-11838 CordovaBackgroundUpload com.appname D eventLabel=Uploader starting uploads via worker0
2023-10-06 07:57:00.323 11546-11957 Compatibil...geReporter com.appname D Compat change id reported: 194532703; UID 10686; state: ENABLED
2023-10-06 07:57:00.339 11546-11957 ConnectivityManager com.appname D StackLog: [android.net.ConnectivityManager.sendRequestForNetwork(ConnectivityManager.java:4322)] [android.net.ConnectivityManager.registerDefaultNetworkCallbackForUid(ConnectivityManager.java:4886)] [android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:4853)] [android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:4827)] [androidx.work.impl.utils.NetworkApi24.registerDefaultNetworkCallbackCompat(NetworkApi24.kt:28)] [androidx.work.impl.constraints.trackers.NetworkStateTracker24.startTracking(NetworkStateTracker.kt:139)] [androidx.work.impl.constraints.trackers.ConstraintTracker.addListener(ConstraintTracker.kt:57)] [androidx.work.impl.constraints.controllers.ConstraintController.replace(ConstraintController.kt:82)] [androidx.work.impl.constraints.WorkConstraintsTrackerImpl.replace(WorkConstraintsTracker.kt:92)] [androidx.work.impl.background.greedy.GreedyScheduler.schedule(GreedyScheduler.java:170)] [androidx.work.impl.Schedulers.schedule(Schedulers.java:119)] [androidx.work.impl.utils.EnqueueRunnable.scheduleWorkInBackground(EnqueueRunnable.java:135)] [androidx.work.impl.utils.EnqueueRunnable.run(EnqueueRunnable.java:95)] [androidx.work.impl.utils.SerialExecutorImpl$Task.run(SerialExecutorImpl.java:96)] [java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)] [java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)] [java.lang.Thread.run(Thread.java:1012)]
2023-10-06 07:57:00.345 11546-11546 CordovaBackgroundUpload com.appname D Task succeeded: e6b53e05-777a-4536-ba68-944cd915b314
2023-10-06 07:57:00.346 11546-11546 CordovaBackgroundUpload com.appname D eventLabel='Uploader failed inexplicably' error='Data {output_failure_canceled : false, output_is_error : true, output_failure_reason : File not found !, output_id : e0450a9d-f0a7-45dc-8eac-5bfcfd317450, }'
2023-10-06 07:57:00.372 11546-11546 CordovaBackgroundUpload com.appname D Task succeeded: 53988ed2-1ce3-4085-901b-641865cb8053
2023-10-06 07:57:00.372 11546-11546 CordovaBackgroundUpload com.appname D eventLabel='Uploader failed inexplicably' error='Data {}'
2023-10-06 07:57:00.384 11546-11960 CordovaBackgroundUpload com.appname E doWork: File not found !
java.io.FileNotFoundException: /sdcard/.transforms/synthetic/picker/0/com.android.providers.media.photopicker/media/1000007028.mp4: open failed: EFAULT (Bad address)
at libcore.io.IoBridge.open(IoBridge.java:574)
at java.io.FileInputStream.<init>(FileInputStream.java:160)
at com.spoon.backgroundfileupload.UploadTask.createRequest(UploadTask.java:345)
at com.spoon.backgroundfileupload.UploadTask.doWork(UploadTask.java:178)
at androidx.work.Worker$1.run(Worker.java:82)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
Caused by: android.system.ErrnoException: open failed: EFAULT (Bad address)
at libcore.io.Linux.open(Native Method)
at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:274)
at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8624)
at libcore.io.IoBridge.open(IoBridge.java:560)
at java.io.FileInputStream.<init>(FileInputStream.java:160)
at com.spoon.backgroundfileupload.UploadTask.createRequest(UploadTask.java:345)
at com.spoon.backgroundfileupload.UploadTask.doWork(UploadTask.java:178)
at androidx.work.Worker$1.run(Worker.java:82)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
2023-10-06 07:57:00.386 11546-11957 WM-WorkerWrapper com.appname I Worker result SUCCESS for Work [ id=53988ed2-1ce3-4085-901b-641865cb8053, tags={ com.spoon.backgroundfileupload.UploadTask, work_tag_upload } ]
2023-10-06 07:57:00.395 11546-11546 ConnectivityManager com.appname D StackLog: [android.net.ConnectivityManager.unregisterNetworkCallback(ConnectivityManager.java:4996)] [androidx.work.impl.utils.NetworkApi21.unregisterNetworkCallbackCompat(NetworkApi21.kt:31)] [androidx.work.impl.constraints.trackers.NetworkStateTracker24.stopTracking(NetworkStateTracker.kt:154)] [androidx.work.impl.constraints.trackers.ConstraintTracker.removeListener(ConstraintTracker.kt:73)] [androidx.work.impl.constraints.controllers.ConstraintController.replace(ConstraintController.kt:80)] [androidx.work.impl.constraints.WorkConstraintsTrackerImpl.replace(WorkConstraintsTracker.kt:92)] [androidx.work.impl.background.greedy.GreedyScheduler.removeConstraintTrackingFor(GreedyScheduler.java:243)] [androidx.work.impl.background.greedy.GreedyScheduler.onExecuted(GreedyScheduler.java:229)] [androidx.work.impl.Processor.onExecuted(Processor.java:385)] [androidx.work.impl.Processor$FutureListener.run(Processor.java:484)]
2023-10-06 07:57:00.407 11546-11546 CordovaBackgroundUpload com.appname D Task succeeded: 53988ed2-1ce3-4085-901b-641865cb8053
2023-10-06 07:57:00.407 11546-11546 CordovaBackgroundUpload com.appname D eventLabel='Uploader failed inexplicably' error='Data {output_failure_canceled : false, output_is_error : true, output_failure_reason : File not found !, output_id : e0450a9d-f0a7-45dc-8eac-5bfcfd317450, }'
Even worse is there is no way to purge the upload queue to remove this problem upload, so no new uploads work without uninstalling and reinstalling the app (opened a separate issue for that)
Metadata
Metadata
Assignees
Labels
No labels