In your situation, I would be tempted to contribute to the Roth, then the 401k for the simple reason the Roth *contributions* (NOTE: not return on investment) can be withdrawn at any time penalty free. Withdrawal of funds in a 401k are penalized 10% if withdrawn before age 59-1/2 (or age 55 if the person quits, is fired from, or retires from their 401k sponsoring job in the year they will turn age 55 - see 'rule of 55').
People who quit/retire before younger than age 55 generally roll their 401k to a rollover IRA, and after FIRE begin converting funds from their IRA to a Roth IRA (see 'Roth IRA Conversion Ladder').
But with the Roth, your contributions can be withdrawn at any time. So, Roth first.