Gist #2 below provides a more concise explanation of what I believe is going wrong and causing decoding to fail. I am leaving gist #1 up, but would recommend readers to read Gist #2 first to get a better understanding of the problem.
Breaking code:
let primaryStruct = await program.account.primaryStruct.fetch(stateAccount);
The error: