96 nissan pickup

the old truck acts like it has a rev limiter. At about 2500rpms the engine shuts off and as soon as it gets below 2500rpms it fires back up. Now this problems comes and goes and when it runs like is should it runs just fine. I have had codes pulled up and it tells us that it is a mass air sensor, but that’s doesn’t seemed to be it. I have replaced the followings; o2 sensor. plugs, plug wires,rotor button,dist cap,fuel pressure reg,mass air flow sensor.

Anyone got any ideas before i go and have a dealership look at it