zxing-js/library

Safari requesting url `undefined` during image cleanup

lewismoten opened this issue · 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)

// then forget about that element 😢
this.imageElement.src = undefined;
this.imageElement.removeAttribute('src');
this.imageElement = undefined;