You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Micro Runtime Cleanup 3: Add service lastError() and centralize runtime error recording #73
Service runtime failures need a first-class PHP-visible path. Before layering on reset/stop/control-subject work, the service should have one consistent way to record errors and expose them to callers.
Goal
Introduce Service::lastError() and a single internal recordError() path that all runtime failures can use without breaking cleanup or reply flow.
Scope
src/Micro/Service.php
src/Micro/ServiceInterface.php
tests/Integration/Micro/ServiceTest.php
tests/Integration/Micro/StatsHandlerTest.php only if shared helpers/assertions need updating
Deliverables
lastError(): ?\Throwable on the service API
centralized runtime error recording inside Service
throwing user errorHandler callbacks cannot break the main error path
response-send failures become observable from the service layer
Out of scope
duplicate-reply suppression details
graceful stop/drain refactor
docs refresh
Acceptance criteria
handler exceptions update lastError() and endpoint stats
response-send failures update lastError()
a throwing errorHandler does not swallow the original runtime failure or break cleanup/reply flow
integration coverage exists for the above behavior
Parallelism
Can start immediately.
Blocks reset semantics, control-subject hardening, and graceful stop/drain work because those paths should all use the same error-recording helper.
Activity
matkomat commentedon Mar 31, 2026
Implementation plan for whoever picks this up:
Goal
Service::lastError().recordError()path inside the micro service layer.main, not from PR fix: tighten micro service semantics #70 or any follow-up branch.Target API after this issue
Public service API should gain:
ServiceInterface::lastError(): ?\ThrowableService::lastError(): ?\ThrowableInternal service behavior should gain:
?\Throwable $lastErrorfield inServicerecordError(\Throwable $e): voidhelper that:errorHandler, if presenterrorHandlerScope
Touch only what is needed for this issue:
src/Micro/Service.phpsrc/Micro/ServiceInterface.phptests/Integration/Micro/ServiceTest.phptests/Integration/Micro/StatsHandlerTest.phponly if needed for shared assertions or compile falloutWhat should change in Service behavior
recordError($e)so callers can inspectlastError().recordError().ServiceConfig::errorHandleritself throws, that must not replace or erase the original runtime failure.lastError().Test changes
Add or port focused integration coverage for these paths:
lastError()and endpoint statserrorHandlerdoes not break the main error flowlastError()Preferred naming direction:
testHandlerFailureIsExposedThroughLastErrorAndStatstestThrowingErrorHandlerDoesNotBreakErrorFlowtestResponseSendFailureIsObservableDo not add tests here for:
reset()semanticsstop()/ deferred cleanupThose belong to later issues.
Explicit non-goals / forbidden changes
src/Message.phpsrc/Micro/RequestInterface.phphasResponded()or any duplicate-reply bookkeeping hereService::stop()here beyond trivial compile fallout, if anyAcceptance checklist
ServiceInterfaceexposeslastError(): ?\ThrowableServicestores and returns the latest runtime errorlastError()lastError()errorHandlerdoes not break the main runtime error pathSuggested verification
vendor/bin/phpunit tests/Integration/Micro/ServiceTest.phpvendor/bin/phpunit tests/Integration/Micro/StatsHandlerTest.phpif touchedReview notes
The review for this issue will check specifically for:
stop(),reset(), or control-subject hardeningsrc/Message.phpeditslastError()truly reflects the original runtime failure whenerrorHandleralso throws