Skip to content

Commit 4384c50

Browse files
authored
test: clear the last error in the parse errors worker script (#2799)
#2790 stopped resetting `error_get_last()` between worker requests, so `TestWorkerSurvivesRequestParseErrors` fails on main. The worker script now calls `error_clear_last()` itself, as the worker docs recommend.
1 parent 9d47446 commit 4384c50

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎testdata/request-parse-errors.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
if ($lastError && $lastError['type'] === E_WARNING) {
1717
http_response_code(400);
1818
echo $lastError['message'];
19+
// The last error persists between requests like userland state
20+
error_clear_last();
1921
}
2022

2123
++$requests;

‎worker_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestWorkerSurvivesRequestParseErrors(t *testing.T) {
6868
assert.Contains(t, body2, "requests:2")
6969
assert.Contains(t, body2, "exceeds the limit")
7070

71-
// clean request: recorded errors must be reset between requests
71+
// clean request: the script cleared the previous error itself
7272
body3, resp3 := testGet("http://example.com/request-parse-errors.php", handler, t)
7373
assert.Equal(t, http.StatusOK, resp3.StatusCode)
7474
assert.Contains(t, body3, "requests:3")

0 commit comments

Comments
 (0)