This is more common with closed cell foam, but it happens with open cell foam, too. Since closed cell foam has a higher R-value per inch, installers generally spray 2" in walls and 3" in rooflines to meet the energy code requirements of R-13 and R-19, respectively. (I'm not going to dive into the energy code here, but these numbers apply to many climate zones, the latter being allowed under the UA tradeoffs rule. See the Energy Nerd's blog on this topic if you want to argue.)
Spray foam insulation, also known as foaming insulation or sprayed insulation, is a two-part liquid insulation material that insulates and air seals wherever it is applied. The material comes in two large 55 gallon drums – an iso and a resin. These two liquids are kept separate until applied at the jobsite by a qualified, licensed spray foam installer. The two liquids travel up through a heated hose to the spray gun where they are combined to create the foam. The foam expands within seconds to fill the cavity surface.  Depending on the type of sprayed-in foam insulation used, closed-cell or open-cell, the foam expands between 40 and 100 times its size upon application. 
Spray foam insulation is a great product. Homes insulated with it can be some of the most efficient and comfortable homes built. I've been in plenty of these homes and can tell you that when spray foam is installed properly, they outperform 99% of fiberglass batt-insulated, stick-built homes. (I can also tell you that 73% of all statistics are made up on the spot, so please don't ask for documentation of that statistic.)
Today, each of the 50 states follows a different set of building codes making navigating these codes confusing, particularly for architects or builders that have projects in multiple states. In some cases, the building code changes significantly between the state and certain cities or counties within the state. For example, at the time of writing Arizona had adopted the 2015 IRC Building Code, however, Phoenix was on the 2012 IRC, IBC and IECC code. With the majority of states either on the 2009, 2012 or 2015 code, below are some high-level points to consider and about how spray foam insulation contributes.

This is in great contrast to my friend's experience. Her attic spaces were sprayed and the foam is actually pretty, and I was in her attic 6-7 days after it was sprayed and could hardly smell anything when I stuck my face up to the foam. And she did not have to clean up one speck of dust during or after the spraying. I got the name/number of the guy from her who managed her attic project, but between the time he did my house and the time he did her house, he was let go from the company who did her attic and hired by another company. He assured me everything would be the same, etc., etc., and I had no reason to believe anything had changed, but the sprayers who did my house later admitted they had never sprayed an attic before and I also found out that the foam used in my attic was from a different manufacturer. Neither my friend nor I had any idea this guy was with different company then, until the week after they filled my attic with off ratio foam, and my home with toxic vapors.  

How Much Is Spray Foam Roof Insulation

They’re the more expensive option than the first one we have discussed above, but they also offer top benefits for the RV owners who want to repair or maintain their RV roof and protect it from UV rays and harsh weather elements. Based on many reviews, these types can offer more durability than the silicone and acrylic types. They can also offer an excellent impact resistance from twigs, leaves and other outer elements.
This stuff works GREAT ! I live in an older mobile home that had a lot of leaks when I moved-in. I worked for two years to locate and fix them all. Now I simply go over all of the repaired places once a year just to be sure everything is OK. NO LEAKS FOR 4 YEARS NOW!!  Others here use "sno proof" or something that does not stop leaks. When I tell them about my success, they don't seem to want to pay the$ for this superior product. Too bad!. I used the tape in  repairing the leaks.

The problem was that the installer was doing his first spray foam job ever, and the thickness of the insulation varied from zero (visible roof deck) to about 9". Unfortunately, good average thickness doesn't cut it. The coverage needs to be uniform because a lot of heat will go through the under-insulated areas. (See my article on flat or lumpy insulation performance.)
The United States has adapted to using sprayfoam insulation and a new technology called Wall Injection to retrofit existing wall construction by drilling small holes between wall studs in the structures framing and filling the void with a less aggressive expanding water based foam. This allows existing home and business owners to conserve energy by creating a thermal envelope in their existing structure.

Roof Coating Seal