Freshly generated snapshot is corrupt #2827
Replies: 11 comments
-
That's strange! The snapshot format has changed in AVA 4 (in pre-release). Do you think you could give that a go? Perhaps the problem goes away… see https://github.com/avajs/ava/releases/tag/v4.0.0-alpha.2 and https://github.com/avajs/ava/releases/tag/v4.0.0-alpha.1. |
Beta Was this translation helpful? Give feedback.
-
@novemberborn Thanks for the suggestion. I wasn't aware there was a AVA 4 pre-release. Unfortunately, the same error occurs. This PR updates the previously linked test to AVA 4 with new snapshots: prismicio/prismic-mock#1 I can get around this by not using snapshots for those tests so it's not blocking me. I'm happy to help diagnose the issue, however. Thank you! |
Beta Was this translation helpful? Give feedback.
-
In case it is relevant, here is my local system info where tests pass:
|
Beta Was this translation helpful? Give feedback.
-
Hey @angeloashmore I haven't had a chance yet to look into this further. |
Beta Was this translation helpful? Give feedback.
-
@novemberborn Not a problem! I really appreciate you following up. |
Beta Was this translation helpful? Give feedback.
-
@angeloashmore sorry for the wait. I couldn't actually run the tests from prismicio/prismic-mock#1 but I copied a snapshot file into a separate project and set things up so AVA would load it. AVA snapshots start with some readable text, followed by a version number, followed by a SHA256 checksum of the rest of the file. This checksum is corrupted. This is how the checksum is computed and the data is prepared before file is written: Lines 190 to 196 in 725c5d6 And how the checksum is compared: Lines 221 to 223 in 725c5d6 I don't see room for false positives there, so I'm pretty confident the snapshot is corrupted. Indeed Why that is happening I do not know. My best guess is that there are concurrent writes, except that we're (attempting) to write the files atomically. And regardless that assumes you're running the same test file twice, concurrently. Perhaps you can try and isolate the error? |
Beta Was this translation helpful? Give feedback.
-
@novemberborn Thanks for taking a look, and sorry about the I'll try to come up with a smaller reproduction and narrow down what triggers this to happen. Thanks for the details! |
Beta Was this translation helpful? Give feedback.
-
Hi, I have the exact same issue on AVA 4.0 I can delete the file, run tests to create the snapshots, re-run the tests -> it complains that the file is corrupted. I don't have a small repro case, but everything I have is pushed in that branch : https://github.com/swissquote/crafty/tree/ava-integration-tests Steps to see the error:
Running the full test suite shows more corrupt files, but this is the shortest path to see errors. My environment:
I can run more tests and experiments if you need me to, I'm not exactly sure where to start though |
Beta Was this translation helpful? Give feedback.
-
I experienced a similar issue as the original commenter on v4.0.0 and it was fixed by v4.0.1 |
Beta Was this translation helpful? Give feedback.
-
Indeed it does seem to work with 4.0.1 👍 |
Beta Was this translation helpful? Give feedback.
-
Thanks for the heads up @jonahsnider! |
Beta Was this translation helpful? Give feedback.
-
Hi there!
AVA reports the the following error when using snapshots. The snapshot has been freshly generated locally and pushed to GitHub to run in an GitHub Actions workflow.
This error only appears when running within GitHub Actions. The test passes locally.
Any idea what could cause a corrupted snapshot to be generated?
Relevant files and tests:
Test: https://github.com/prismicio/prismic-mock/blob/97861bf3cf46cb9a42c6e2b5d6b4c5c60aab6cd2/test/value-group.test.ts#L8
Macro used by the test: https://github.com/prismicio/prismic-mock/blob/97861bf3cf46cb9a42c6e2b5d6b4c5c60aab6cd2/test/__testutils__/snapshotTwiceMacro.ts#L3-L8
Snapshot (Markdown): https://github.com/prismicio/prismic-mock/blob/97861bf3cf46cb9a42c6e2b5d6b4c5c60aab6cd2/test/snapshots/value-group.test.ts.md
Snapshot (binary): https://github.com/prismicio/prismic-mock/blob/97861bf3cf46cb9a42c6e2b5d6b4c5c60aab6cd2/test/snapshots/value-group.test.ts.snap
Failing test: https://github.com/prismicio/prismic-mock/runs/3305415519?check_suite_focus=true#step:7:199
AVA config
AVA version
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions