Adri-Glez / filepond-plugin-pdf-preview

Show a preview for PDFs dropped on FilePond
MIT License
20 stars 14 forks source link

Uncaught TypeError: Cannot read property 'file' of null #2

Closed nh-mdev closed 3 years ago

nh-mdev commented 3 years ago

Describe the bug Using vue-filepond with the pdf preview plugin, sometimes the stacktraced error occurs on route change.

To Reproduce 1) Uploading an image 2) Waiting for it to succeed 3) Navigating away from the current route 4) Going back to upload view 5) Remove current image 6) Upload new image 7) Navigate away from current route

Expected behavior No console TypeError.

Stacktraces

Uncaught TypeError: Cannot read property 'file' of null
    at filepond-plugin-pdf-preview.js:181
    at filepond.js:1445
    at filepond.js:1096
    at Array.forEach (<anonymous>)
    at Object._write (filepond.js:1095)
    at filepond.js:1125
    at Array.forEach (<anonymous>)
    at Object._write (filepond.js:1123)
    at filepond.js:1125
    at Array.forEach (<anonymous>)

Information about your project: Windows 10 Google Chrome - Version 89.0.4389.90 (64-Bit)

"filepond": "^4.21.1"
"filepond-plugin-file-encode": "^2.1.9"
"filepond-plugin-image-preview": "^4.6.4"
"filepond-plugin-file-validate-type": "^1.2.6"
"filepond-plugin-image-transform": "^3.7.6"
"filepond-plugin-pdf-preview": "^1.0.2"
"filepond-plugin-file-validate-size": "^2.2.4"
"vue-filepond": "^6.0.3"

Additional context I tried "resolving/catching" this error in the beforeDestroy() life-cycle hook of the component holding vue-filepond, but the this.$refs is already undefined at that point.

Adri-Glez commented 3 years ago

I can't reproduce it. Maybe is something in your Vue Project.

It happens when you upload a image or a pdf? Looks like is something that do Vue on the variable context when the route change.

Sure If we put a null check in the error line 181 Will be another null error elsewhere. The thing is know why It execute the method when the route change, maybe It shouldn't at this point, and why is null because there are a file on it, isn't it?

Anyway I can’t reproduce it, I think is something that should be fixed in your project environment, If you find a reason and a robust fix for it we can change the library.

Delta-Band commented 3 years ago

@Adri-Glez Happens to me when I upload a PDF Using React

simonmaass commented 3 years ago

can confirm this issue using vue

symbianm commented 3 years ago

It happens to me too in React. Hard to reproduce, but the issue exists. See attached error log.

Screenshot 2021-10-20 at 10 20 04 Screenshot 2021-10-20 at 10 28 01
alkanna commented 2 years ago

Same here on svelte.

leeovery commented 2 years ago

Same here on Vue + nuxt

simonmaass commented 2 years ago

@Adri-Glez looks like quite a few people have this issue - maybe reopen this?

AO-IO commented 2 years ago

issue still there ... when changing the route the error is triggered ... vue 2 (Nuxt) 😕

image