Skip to content

Commit 7882c93

Browse files
authored
[Bref] Restart after uncaught exception (#82)
* [Bref] Restart after uncaught exception * csfix * Added changelog * Use exit code 0
1 parent 63c41a7 commit 7882c93

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"require": {
13-
"bref/bref": "^1.2",
13+
"bref/bref": "^1.3",
1414
"clue/arguments": "^2.1",
1515
"guzzlehttp/psr7": "^1.8 || ^2.0",
1616
"illuminate/contracts": "^8.33",

src/bref/CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## [NOT RELEASED]
44

5+
## 0.2.2
6+
7+
### Fixed
8+
9+
- Make sure to restart process if there is an uncaught exception
10+
511
## 0.2.1
612

713
### Added
@@ -12,12 +18,12 @@
1218

1319
### Added
1420

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

1824
### Fixed
1925

20-
- Session handling for Symfony 5.4 and up.
26+
- Session handling for Symfony 5.4 and up
2127
- Error handling on invalid `_HANDLER` string
2228

2329
## 0.1.1

src/bref/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
],
1212
"require": {
1313
"ext-json": "*",
14-
"bref/bref": "^1.2",
14+
"bref/bref": "^1.3",
1515
"clue/arguments": "^2.1",
1616
"psr/http-server-handler": "^1.0",
1717
"riverline/multipart-parser": "^2.0",

src/bref/src/BrefRunner.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ public function run(): int
3131
if (++$loops > $this->loopMax) {
3232
return 0;
3333
}
34-
$lambda->processNextEvent($this->handler);
34+
35+
/**
36+
* In case the execution failed, we force starting a new process regardless
37+
* of $this->loopMax. This is because an uncaught exception could have
38+
* left the application in a non-clean state.
39+
*/
40+
if (!$lambda->processNextEvent($this->handler)) {
41+
return 0;
42+
}
3543
}
3644
}
3745
}

0 commit comments

Comments
 (0)