library icon indicating copy to clipboard operation
library copied to clipboard

Safari requesting url `undefined` during image cleanup

Open lewismoten opened this issue 9 months ago • 0 comments

Hello. I noticed that my server was getting hit with tons of requests for /undefined. Although the response was only 238 bytes, the great number of the requests per second (less than 60) was adding up. I tracked the problem down to BrowserCodeReader.ts on line 1161 during image cleanup in the _destroyImageElement function. Before removing the image src attribute, it is assigned the value of undefined. In the Safari web browser on macOS, this results in a request as if undefined is an expected resource. I do not see this behavior in Google Chrome.

Environment Name Version
Operating System Apple macOS Sonoma 14.2.1
Browser Apple Safari 17.2.1 (19617.1.17.11.12)
Browser Google Chrome 124.0.6367.203 (Official Build) (arm64)

https://github.com/zxing-js/library/blob/7b0f4e907e4d59565e6f2be35f714a7500294c30/src/browser/BrowserCodeReader.ts#L1159-L1163

lewismoten avatar May 20 '24 00:05 lewismoten