Closed VeljkoMaksimovic closed 2 years ago
We have fixed bugs related to this in the past. Please update to Elixir v1.13.4 and let us know if it continues. Thank you!
@josevalim Updated to version 1.13.4
Erlang/OTP 24 [erts-12.3.2] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1]
Elixir 1.13.4 (compiled with Erlang/OTP 23)
Error still persists. I ran same test script 15 times, 2 passes had this error, and other 13 times all tests executed as expected.
The script contains 7 tests, and its not the case that error occurres always during the execution of same test. It is always triggered by different tests.
Thank you! How are you running tests? Are you loading multiple files or a single file?
Single file with command mix test _path_to_test_file_
Is it async: true
or async: false
? If the former, does it error with async: false
?
I was running it asynchronously. When I switch to async: false
everything is working fine, and I cant reproduce the error.
Ok, I know what is happening: :meck
replaces a module globally and while the test is running (async: true starts running it as soon as it is defined), the compiler is doing code verification. However, the compiler cannot find the struct definition because :meck
temporarily removed or replaced the module.
You should use async: false
or use something else for mocking, because :meck
is literally not safe for concurrent usage.
Edit: also see #11218.
Elixir and Erlang/OTP versions
Erlang/OTP 24 [erts-12.3.2] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1]
Elixir 1.12.1 (compiled with Erlang/OTP 24)
Operating system
Had this issuee on Ubuntu18.04 and macOS Monterey 12.1
Current behavior
This error occurres from time to time when running unit tests. If I run same test again, it all works good.
Expected behavior
Running same code works ~ 9 out of 10 times