Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase robustness #24

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bzikarsky
Copy link

This commit tackles issues in the codebase around unterminated promises. Unreturned promises should always be terminated with done().

The MR consists of two commits (each with a descriptive commit message, please read for details):

  1. Overhaul the testsuite - It proved to be a bit inflexible and suffered also from the the vs done issue
  2. Fix the actual implementation

This commit overhauls the test quite a bit:
- MQTT Hostname and port can be overridden via environment variable
- Deprecated reactPHP APIs are updated
  - reject vs new RejectedPromise
  - EventLoop\Factory vs Loop::get
- Tests assert now that the callback chain is executed with a flag that is
  checked at the end
- All non-returned promises are now terminated with `done()` to make sure that
  all exceptions are handled/thrown
- Removed unused DNS resolver - default loop works out of the box
- PHPUnit now forces error_reporting to E_ALL
  This uncovers an E_DEPRECATED in react/promise (needs to be fixed upstream)
The currently existing E_DEPRECATED in the reactphp Promise code surfaced an
interesting bug: When you run the ReactMqttClient in an environment that e.g.
throws that E_DEPRECATED as an exception `->otherwise` chains may not be
executed, because the promise-callback-chains are not terminated with `done()`.

This can (currently) be simulated by setting an aggressive error-handler in the
testsuite:

```
set_error_handler(function ($_type, $message) {
   throw new Error($message);
});
```

Testcase that rely on promise rejections (e.g. test_connect_failure) will hang
until the test times out.

This commit fixes all non-returned callback-chains with a `done()`-termination
as it is best-practice.
@bzikarsky
Copy link
Author

The fix for the E_DEPRECATED is in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant