zfcampus / zf-mvc-auth

BSD 3-Clause "New" or "Revised" License
42 stars 46 forks source link

Early Exception Issue #54

Open spectravp opened 9 years ago

spectravp commented 9 years ago

Not sure if this is even solvable since the component and its associated database connections (from OAuth) are required early, but here's the issue:

As any good developer should have, we have extensive error reporting and logging in place, emails, sms messages, etc and we have wrapped this logic into a module. But in this case, we had no notice of a critical error.

Our database server went away. The MvcAuth component attempts to retrieve a DB instance from the OAuth component on Bootstrap. Since the database server went offline, it rightly threw an exception. However, since this all occurred on bootstrap, the code in our ErrorReporter module never executed and the user was greeted with a blank white page. Since this occurred on bootstrap we couldn't route the user to a pretty "Whoops" page nor were we alerted.

The only solution at this time was to wrap the contents of public/index.php in a try catch statement, code out some error reporting and issue a die() statement to the user. Furthermore, because this all happens on bootstrap, the error occurs on pages where the DB connector and the Auth aren't even required.

In my opinion, this instantiation and configuration should happen elsewhere in the event chain so that the developer can programmatically and intelligently handle such errors.

EMCP commented 9 years ago

Can you not load your ErrorReporter module before the offending module, in this case MvcAuth ?

spectravp commented 9 years ago

Tried that. Doesn't work cause the exception stops the whole bootstrap process in its tracks. No standard error routing, just kaput.

EMCP commented 9 years ago

Perhaps this means modifying the factory in which Mvc-Auth generates it's objects? I've been wondering how to code defensively in cloud environments myself, since this can and will happen.

spectravp commented 9 years ago

This also means that console routes fail. We now have a single application split into multiple instances simply to bypass the MvcAuth component which is terrible.

weierophinney commented 4 years ago

This repository has been closed and moved to laminas-api-tools/api-tools-mvc-auth; a new issue has been opened at https://github.com/laminas-api-tools/api-tools-mvc-auth/issues/18.