Ive noticed something in 2.2 that is not the same behaviour as m1, in the layered navigation any out of stock products the attributes don't show if it's out of stock.This is for simple products that I'm having the issue. And set to show out of stock products.
If i set the product to in stock the color attribute for that product - example "Red" then comes back into the list of colors.
If the product is out of stock it still shows in the category list but the attribute is then hidden from the layered navigation color attribute list but if i use the url to access the filter directly when it was in stock i copied the url, and viewing it in a new tab the collection loads and does not create an error, is this a bug that the attribute is not showing when the product is out of stock if not what would I be able to do to allow the attribute to show even when out of stock.
change this file
mainly below thing:- $subSelect->where('stock_index.stock_status = ?', Stock::STOCK_IN_STOCK);
and do reindex and check it.
If that work then mark as solution