rspec-wait
rspec-wait copied to clipboard
rip out Timeout.timeout
- consequence: long-running blocks are not interrupted
- 7 tests fail, expecting TimeoutError but getting ExpectationNotMetError
Note: I have not patched up the failing tests
Rationale for this: https://jvns.ca/blog/2015/11/27/why-rubys-timeout-is-dangerous-and-thread-dot-raise-is-terrifying/
There is no way to safely interrupt an arbitrary block of code.
So this PR abandons the feature of interrupting an arbitrary block of code. If one passes a block that loops forever, rspec-wait will never finish. In exchange for dropping this feature, rspec-wait should be easier to reason about and have much lower potential for Timeout.timeout
bugs relating to concurrency, MRI internals, etc.
Oh, L11-13 (HAX!) are there so that more tests pass than would otherwise. These 3 lines should be rewritten to a simple single line once the tests stop expecting TimeoutError
.
A comment in support of this change.
I recently monkey patched rspec_wait to do this (I was was going to submit a PR before I saw someone beat me to it)
The reason I monkey patched was that our test suite started hanging randomly where the condition wait_for was waiting for became true, but the loop was never interrupted. I traced this to Timeout.timeout being unsafe as described above.
Just wanted to let you know that this isn't just a theoretical issue :)