prooph / event-store-http-client

PHP 7.2 Event Store HTTP Client Implementation
BSD 3-Clause "New" or "Revised" License
25 stars 5 forks source link

Notice: Undefined index: lastCheckpoint #31

Closed enumag closed 5 years ago

enumag commented 5 years ago

Today I encountered an error Notice: Undefined index: lastCheckpoint on this line. It started right after I added a reorderEvents option to my projection (see docs). When I dumped $entry it contains this:

array (
  'coreProcessingTime' => 0,
  'version' => -1,
  'epoch' => -1,
  'effectiveName' => 'everything',
  'writesInProgress' => 0,
  'readsInProgress' => 0,
  'partitionsCached' => 0,
  'status' => 'Faulted',
  'stateReason' => 'Event reordering requires processing lag at least of 50ms',
  'name' => 'everything',
  'mode' => 'Continuous',
  'position' => '',
  'progress' => 0.0,
  'eventsProcessedAfterRestart' => 0,
  'statusUrl' => 'http://eventstore-ci:2113/projection/everything',
  'stateUrl' => 'http://eventstore-ci:2113/projection/everything/state',
  'resultUrl' => 'http://eventstore-ci:2113/projection/everything/result',
  'queryUrl' => 'http://eventstore-ci:2113/projection/everything/query%3Fconfig=yes',
  'enableCommandUrl' => 'http://eventstore-ci:2113/projection/everything/command/enable',
  'disableCommandUrl' => 'http://eventstore-ci:2113/projection/everything/command/disable',
  'bufferedEvents' => 0,
  'writePendingEventsBeforeCheckpoint' => 0,
  'writePendingEventsAfterCheckpoint' => 0,
)

Notably aside from lastCheckpoint key the checkpointStatus key is missing as well.

Obviously there is an error, see status and stateReason but it should not crash like this with undefined index in my opinion. An exception would be better.

prolic commented 5 years ago

Ah this is because the projection is new and never run, right? We may need make the value nullable on the ProjectionDetails. Wanna submit a PR?

Sascha-Oliver Prolic

Am Do., 14. Feb. 2019 um 17:06 Uhr schrieb Jáchym Toušek < notifications@github.com>:

Today I encountered an error Notice: Undefined index: lastCheckpoint on this line https://github.com/prooph/event-store-http-client/blob/eea9e0e42d64f21fe4e7bd0070fa1d82a80a242e/src/Projections/ProjectionsManager.php#L511. It started right after I added a reorderEvents option to my projection (see docs https://eventstore.org/docs/projections/user-defined-projections/index.html#options). When I dumped $entry it contains this:

array ( 'coreProcessingTime' => 0, 'version' => -1, 'epoch' => -1, 'effectiveName' => 'everything', 'writesInProgress' => 0, 'readsInProgress' => 0, 'partitionsCached' => 0, 'status' => 'Faulted', 'stateReason' => 'Event reordering requires processing lag at least of 50ms', 'name' => 'everything', 'mode' => 'Continuous', 'position' => '', 'progress' => 0.0, 'eventsProcessedAfterRestart' => 0, 'statusUrl' => 'http://eventstore-ci:2113/projection/everything', 'stateUrl' => 'http://eventstore-ci:2113/projection/everything/state', 'resultUrl' => 'http://eventstore-ci:2113/projection/everything/result', 'queryUrl' => 'http://eventstore-ci:2113/projection/everything/query%3Fconfig=yes', 'enableCommandUrl' => 'http://eventstore-ci:2113/projection/everything/command/enable', 'disableCommandUrl' => 'http://eventstore-ci:2113/projection/everything/command/disable', 'bufferedEvents' => 0, 'writePendingEventsBeforeCheckpoint' => 0, 'writePendingEventsAfterCheckpoint' => 0,)

Notably aside from lastCheckpoint key the checkpointStatus key is missing as well.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/prooph/event-store-http-client/issues/31, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYEvPXPZ48V-eJ0w0I4imv57MFFr-0tks5vNScqgaJpZM4a7Ikc .

enumag commented 5 years ago

Yeah the projection is new but this error did not occur until I added the reorderEvents and also no longer happens when I fix the problem by adding the processingLag option. It seems to be an edge case caused by the error rather than by the projection being new.

enumag commented 5 years ago

I'm not entirely sure if we should make them nullable. Both lastCheckpoint abd checkpointStatus are strings so we could use ?? ''. I would not normally suggest this but I see there is an empty string instead of null in the array I dumped above as well ('position' => '',).

So do you want nulls or empty strings? I'll send a PR.

prolic commented 5 years ago

I'm fine with either

On Fri, Feb 15, 2019, 00:39 Jáchym Toušek <notifications@github.com wrote:

I'm not entirely sure if we should make them nullable. Both lastCheckpoint abd checkpointStatus are strings so we could use ?? ''. I would not normally suggest this but I see there is an empty string instead of null in the array I dumped above as well ('position' => '',).

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/prooph/event-store-http-client/issues/31#issuecomment-463697787, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYEvPyvIeMVL1HlfmB5nldMPv9Jh389ks5vNZEpgaJpZM4a7Ikc .