I farmed 42,000 coal and Nitrate powder. Popped it in the chem station to make gunpowder, click the max button and set it to crafting gunpowder. A couple of minutes later, I checked my gun powder process and discovered that once I closed the Chem station interface, production was halted, queue was cancelled and all resources were lost. Out of 42,000 coal and Nitrate powder, I got 56 gun powder. I tried it again, with 37,000 and again, queue was cancelled, and mats lost once I closed the interface. Same thing with 35,000, lost everything. It appears that if you exceed 32,767 crafted items in a single production unit queue slot, closing the interface causes the queue to crash and delete all resources.
This is very easy to duplicate, just try crafting 35,000 of anything, close the interface and the queue crashes and all resources are lost. Appears to be using signed Short variables. Not like you can have negative resources. This is impossible to duplicate in a forge since you are limited to 30,000 of all resources. This is NOT so using the chem station since the resources are subtracted from your inventory. Just need to add a check to see if the max exceeds 30,000 and if it does, put a hard cap that no more than 30K items can be crafted in a single queue slot. Either that or have people getting choked over losing massive amounts of resources.
Tried crushing 42,000 stone to sand and they too vanished. So it is not just the Chem Station. It also crashed when I tried to crush 36,000 stone to sand. 6 X 6000 is what the output UI on a cement mixer can support. Would appear the data type of your storage variables needs to be set at least to an unsigned short which would effectively double storage and queue limits. Better yet, change them to integers which would take your crafting queues and item storage to a little over 2 billion. There is no way that this issue would appear then. Characters do not have enough slots to even come close to crafting 2 billion of anything. Even if it's a worry about negative numbers causing errors, best solution, INT over UShort.