My book derived the formula for the acceleration of a rocket at any instant in the following way:
$v_r=$ velocity of gas released from the nozzle relative to the rocket
$dt=$ infintesimal time interval
$dm=$ mass of the gas released from the nozzle in time interval $dt$
$dP=$ momentum of the gas released in time interval $dt$
$F=$ thrust force acting directly opposite to the direction of the release of gas
$M=$ mass of the rocket after time interval $dt$
We know from Newton's 2nd law,
$$F=\frac{dP}{dt}$$
$$\implies F=\frac{dm}{dt}v_r$$
$$\implies a=\frac{1}{M}\frac{dm}{dt}v_r$$
In this derivation, the velocity of the released gas, $v_r$, has been calculated from the perspective of the rocket, which is constantly accelerating, making it a non-inertial frame of reference. Newton's laws don't hold true in non-inertial frames of reference, but we used newton's 2nd law in this derivation. So, how is this derivation correct?
PS: A similar derivation can be found in Fundamentals of Physics by Halliday, Walker & Resnick