henrygd / bigger-picture

JavaScript lightbox gallery for images, video, audio, iframes, html. Zoomable, responsive, accessible, lightweight.
https://biggerpicture.henrygd.me
MIT License
231 stars 17 forks source link

activeItem is undefined #36

Closed multipliedtwice closed 9 months ago

multipliedtwice commented 11 months ago

Line 65 throws an error. Maybe because of cloudflare rocket loader, not sure. But sometimes activeItem is undefined

8.a0ac303b.js:7 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'hasOwnProperty')
    at r.$$.update (8.a0ac303b.js:7:33773)
    at mt (scheduler.6ba28897.js:1:10177)
    at dt (scheduler.6ba28897.js:1:9910)
r.$$.update @ 8.a0ac303b.js:7
mt @ scheduler.6ba28897.js:1
dt @ scheduler.6ba28897.js:1
Promise.then (async)
_t @ scheduler.6ba28897.js:1
ht @ index.6d6c8704.js:4
(anonymous) @ index.6d6c8704.js:4
H @ 8.a0ac303b.js:7
l @ 8.a0ac303b.js:7
await in l (async)
u @ 8.a0ac303b.js:7
c @ 8.a0ac303b.js:7
c @ rocket-loader.min.js:1
henrygd commented 11 months ago

When are you seeing this? When you first load the page? When you try to open a gallery?

It's going to be very difficult to troubleshoot without a reproduction.

multipliedtwice commented 11 months ago

Hello, when opening a gallery. It happens randomly, sometimes even on consequent open.

It's some edge case because I also can't reproduce it locally. It appears only in prod.

Could you hardcode undefined as an input value and suppress the error?

henrygd commented 11 months ago

Have you tried disabling rocket loader? Or excluding your bigger-picture / bundle script?

We can't have activeItem fall back to undefined because it's relied upon in many other parts of the library. As long as the items are valid it should fall back to being the first item.

If it's only happening in production there must be something unique to the production environment that's breaking it.

henrygd commented 9 months ago

Sorry this closed automatically because of commits that referenced it. I don't think the issue is caused by the library but if you still want help figuring it out, let me know.