You compile a program and get ok for everything except while loops -- they all return 0. You check the WAT output and it looks correct. What's likely wrong in the VM?
The most common bug is getting br_if backwards -- forgetting i64.eqz in the compiler, or mishandling the branch direction in the VM. If br_if 1 always triggers (because eqz was omitted), the loop exits immediately. Another common bug: br 0 jumping to the block instead of the loop -- which exits instead of repeating.
Set a breakpoint in the br_if handler. Check: is the popped value 0 or 1? Does it branch or fall through? Trace one iteration manually. The bug is almost always in the interaction between eqz, br_if, and the block/loop distinction.