Skip to content

Commit 0c06f3d

Browse files
committed
JobMiddleware if no return, auto next() or notice developer in error message #1266
1 parent 3ae7104 commit 0c06f3d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/queue/src/Job/JobController.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public function run(): static
230230
return $controller;
231231
}
232232

233-
public function next(): JobController
233+
public function next(): static
234234
{
235235
if ($this->context !== 'middleware') {
236236
throw new \RuntimeException(
@@ -323,6 +323,12 @@ protected function invokeMiddleware(mixed $middleware): mixed
323323
);
324324
}
325325

326+
if ($result === null) {
327+
throw new \UnexpectedValueException(
328+
'Middleware returns null, you may forgot to return JobController::next() in middleware.'
329+
);
330+
}
331+
326332
if ($result instanceof \Throwable) {
327333
throw $result;
328334
}

0 commit comments

Comments
 (0)