Unless you speak with an immigration attorney first, you should not leave or try to enter the US while you have a US immigration application pending. In many cases, you will be able to leave the US and enter the US while your case is pending. You may be in H1B status, which allows you to leave/re-enter the US while a green card application is pending. You may have advance parole, which allows you to leave/re-enter the US.
However, in other cases, leaving the US will cancel your US immigration application, and you may be barred from the US for up to ten years.
When we file a green card application for you (Form I-485, not just I-130 or DS-260), we also file a travel document, also called advance parole document. This document can allow you to leave and re-enter the US while your case is pending. Since 2020, USCIS has drastically slowed the processing of advance parole travel documents. Now, most of our clients do NOT receive advance parole documents before their green card (lawful permanent residence is approved). This means that our clients cannot travel outside of the US while their green card application is pending.
In some cases, we get your travel permit expedited (sped up), but we caution all of our clients that USCIS is being extremely stingy and uncompassionate when it comes to requests to expedite. The current state of USCIS processing of travel documents is unacceptable, especially since these simple documents used to be approved in as little as 6 weeks after submission of a green card application.