zxing-js / library

Multi-format 1D/2D barcode image processing library, usable in JavaScript ecosystem.
https://zxing-js.github.io/library/
Apache License 2.0
2.51k stars 547 forks source link

Safari requesting url `undefined` during image cleanup #597

Open lewismoten opened 6 months ago

lewismoten commented 6 months ago

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