snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

Scope Locations with Full Multiple Companies Support - "Check Compatibility" button breaks webpage

Open uberbrady opened this issue 6 months ago • 2 comments

This seems to be the case when there are many many Assets or Locations or any of the related fields that need to be 'checked' for compatibility. With #17296 we at least made it so that the Settings page will at least load, but on that particular customer instance, clicking the "Check Compatibility" button hangs for a short while, then crashes the entire web page - turning into a plain black screen.

The challenge here is that those checks have to be pretty exhaustive - finding everything with a location_id and making sure that location_id lines up properly with the company_id of the thing itself - do I have that right?

I think it might be possible to simplify some of those queries to instead do some complicated JOIN bits and maybe fetch the mis-matched data that way?

uberbrady avatar Jun 25 '25 15:06 uberbrady

I think this part is key: https://github.com/grokability/snipe-it/blob/73cfdae9e7c4f7961ccfe9270abb9caf6859c92c/app/Helpers/Helper.php#L1613

That's always going to fetch all of the 'thing' in question - whereas what I think we really want is some kind of clever join back to Company to fetch only the things that are cross-linked. I'm not sure though; it's pretty abstractly written so it's hard to think about.

uberbrady avatar Jun 25 '25 15:06 uberbrady

Maybe something like this?

$location->{$keyword}()->whereNotNull('company_id')->where('company_id','!=',$location_company)->get();

Not really sure about that ->{$keyword}() syntax though - that seems a little weird.

uberbrady avatar Jun 25 '25 15:06 uberbrady

In case more info is needed, I just encountered this on a test instance I'm populating: PHP 8.2, Snipe-IT v8.3.6, ~17K assets, ~1200 locations. Clicking the 'Check compatibility' button would hang for a few seconds, then return a 500 error and spawn a black iframe as described above. I could click outside of it to close it and still interact with the app.

Running behind nginx + php-fpm, only error logs were in fpm (nothing in laravel.log):

[10-Dec-2025 15:07:57] WARNING: [pool www] child 10892 said into stderr: "NOTICE: PHP message: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /home/snipeit/snipe-it/vendor/symfony/error-handler/Error/FatalError.php on line 1"

Temporarily increased the memory limit in the fpm pool conf file to successfully execute the check and enable the feature.

druexmachina avatar Dec 10 '25 21:12 druexmachina