ProductGPT
Try the custom AI to help you find products that Reddit loves.
I use a timed feeder. I give meals 12 hours apart (7/7) and the timed feeder goes off at 4 hour intervals in between (11am/3pm/11pm/3am) with a few pieces of kibble inside.
This is the one I use:
https://www.amazon.com/gp/product/B01MFFY7IP/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1
This is all from experience dealing with my corgi's stomach issues.
If it ever happens and you're awake, wait a minute and toss him a piece of kibble. In my experience if he is enthusiastic about food shortly thereafter, its probably acid stomach. If he refuses food for a longer period, say 15 min, an hour or a few hours, it might be pancreatitis. With acid stomach, hes getting the junk that causes the upset stomach out, which is why he'd be more enthusiastic about food after. With pancreatitis, his pancreas is inflamed so he'll stay uncomfortable until it calms down.
You should probably see your vet, either way, but to avoid acid stomach, make sure he gets a few pieces of kibble(5 to 10) every 3-4 hours. I use this timed feeder off amazon. I feed mine exactly 12 hours apart (7am/7pm) and set the timers on it at that time for 4 hours/8 hours (11 am, 3 pm/11pm, 3 am). That way you don't have to worry about it too much while you sleep/are away from home.
https://www.amazon.com/gp/product/B01MFFY7IP/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1
If its pancreatitis or something else, your vet will direct you with how to handle it properly and will need to do a blood test to detect it. There is no great way to treat it other than to wait for him to work through it, at least none that I've found.
Again, seeing your vet is probably important next time it happens, just to rule things out or if its something I didnt list. It took me a few years to figure out he had more than just pancreatitis so I ran around fretting every few weeks thinking he was in this unstoppable pancreatitis siege (he wasn't, he just had acid stomach too).