lazysizes icon indicating copy to clipboard operation
lazysizes copied to clipboard

Uncaught TypeError: queue.d is not a function

Open samstickland opened this issue 3 years ago • 1 comments

Describe the bug

We are intermittently (around 10% of the time) getting this JS error in our automated test suite when ran on CodeShip.

 http://localhost:3001/assets/lazysizes/plugins/include/ls.include.self.js?body=1 62:11 Uncaught TypeError: queue.d is not a function

To Reproduce

This error is reported in the Chrome console when Capybara + Headless Chrome Driver is instructed to load a page that includes lazy images.

Unfortunately we are finding this very difficult to reproduce consistently. It only seems repeated on CodeShip's Linux based CI servers, not our development Macs, and due to the intermittent nature of the bug I suspect it might be a load-induced race condition (e.g. the race condition doesn't happen unless the CPU is quite loaded)

What is the expected behavior:

No JS errors in the log

What happened instead:

 http://localhost:3001/assets/lazysizes/plugins/include/ls.include.self.js?body=1 62:11 Uncaught TypeError: queue.d is not a function

In what environment (browser/device etc.) does this bug happen/not happen:

It only seems to happen 10% of the time on CodeShips CI platform.

Keywords help others to find this issue:

queue.d, CodeShip

samstickland avatar May 25 '21 16:05 samstickland

I also get this bug on one of my pages.

Looking at the source code of ls.include, it seems to be the variable name "queue" is used twice. Once for the queue object and once for an internal queue array inside of that object. https://github.com/aFarkas/lazysizes/blob/1523a4ff4579e170355c7607f445689b43229caf/plugins/include/ls.include.js#L50 https://github.com/aFarkas/lazysizes/blob/1523a4ff4579e170355c7607f445689b43229caf/plugins/include/ls.include.js#L56

On this line there is the call to the queue.d method: https://github.com/aFarkas/lazysizes/blob/1523a4ff4579e170355c7607f445689b43229caf/plugins/include/ls.include.js#L62

@aFarkas I haven't looked further into the race condition, but do you think that could be a source of error? I personally would rename the internal queue array to something else.

donum avatar Jun 09 '22 17:06 donum