Skip to content

Yii2: Logs are not flushed on shutdown #650

@timkelty

Description

@timkelty

Describe the bug

Using Bugsnag with https://github.com/yiisoft/yii2, logged errors are not flushed to Bugsnag with batching enabled.

  • Exceptions seem to work, just not logged errors
  • If I disable batching ($bugsnagClient->setBatchSending(false);

By settings some breakpoints, I can see that the order of operations seems off:

  1. \Bugsnag\Shutdown\PhpShutdownStrategy::registerShutdownStrategy
  2. \Bugsnag\Client::flush (queue is empty)
  3. \Bugsnag\Client::notify (after which, queue has report)

As you can see, flush seems to be getting called before notify, so the reports never get flushed to Bugsnag.

This seems to be because Yii's logger has its own register_shutdown_function to flush its logs, but is always called last. In this case Bugsnag's shutdown needs to be called after, or no logs exist.

Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlogWe hope to fix this feature/bug in the futurefeature requestRequest for a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions