Skip to content

Commit

Permalink
[Bref] Restart after uncaught exception (#82)
Browse files Browse the repository at this point in the history
* [Bref] Restart after uncaught exception

* csfix

* Added changelog

* Use exit code 0
  • Loading branch information
Nyholm committed Sep 20, 2021
1 parent 6217ef2 commit 658645c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [NOT RELEASED]

## 0.2.2

### Fixed

- Make sure to restart process if there is an uncaught exception

## 0.2.1

### Added
Expand All @@ -12,12 +18,12 @@

### Added

- `vendor/bin/bref-local-handler.php` to invoke PSR-11 handlers locally.
- `vendor/bin/bref-local-handler.php` to invoke PSR-11 handlers locally
- Invocation and request context to the Request ServerBag

### Fixed

- Session handling for Symfony 5.4 and up.
- Session handling for Symfony 5.4 and up
- Error handling on invalid `_HANDLER` string

## 0.1.1
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"require": {
"ext-json": "*",
"bref/bref": "^1.2",
"bref/bref": "^1.3",
"clue/arguments": "^2.1",
"psr/http-server-handler": "^1.0",
"riverline/multipart-parser": "^2.0",
Expand Down
10 changes: 9 additions & 1 deletion src/BrefRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ public function run(): int
if (++$loops > $this->loopMax) {
return 0;
}
$lambda->processNextEvent($this->handler);

/**
* In case the execution failed, we force starting a new process regardless
* of $this->loopMax. This is because an uncaught exception could have
* left the application in a non-clean state.
*/
if (!$lambda->processNextEvent($this->handler)) {
return 0;
}
}
}
}

0 comments on commit 658645c

Please sign in to comment.