Upvote:1
Your student status would be unaffected if your flight has to make an emergency landing in another country. Nor would it be if you travelled there yourself.
People in the US on student visas (F and J) do not need a valid visa to re-enter the US under the automatic revalidation scheme, if they traveled to Canada, Mexico, or certain Caribbean islands, for a maximum of 30 days outside the US. Under automatic revalidation, you re-enter the US in your existing status. You should have a copy of your I-94 and I-20 with you (you may need these anyway when departing Puerto Rico).
The official rules for automatic revalidation, as given to air carriers, are available in the Automatic Revalidation Fact Sheet.
However, since you are applying to adjust status to permanent resident, this is much more complicated, and you cannot rely on automatic revalidation. Leaving the US while your application is pending, without advance parole, is considered abandoning it. How this hypothetical situation would affect your application for permanent residence isn't something we can help with here; try our sister site Expatriates for that question.