Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telescope resumes recording after JobProcessing event #719

Closed
erikgaal opened this issue Sep 4, 2019 · 5 comments
Closed

Telescope resumes recording after JobProcessing event #719

erikgaal opened this issue Sep 4, 2019 · 5 comments

Comments

@erikgaal
Copy link
Contributor

erikgaal commented Sep 4, 2019

  • Telescope Version: 2.1
  • Laravel Version: 6.0.0
  • PHP Version: 7.3.8
  • Database Driver & Version: sqlite

Hi there,

In order to speed up some seeds we've added Telescope::stopRecording() at the beginning of the commands/seeds. This should prevent Telescope from recording, however, the seeders are still slower, and consuming more memory compared to having Telescope disabled. This didn't seem right, so I started inspecting with the debugger.

What I found out, was that Telescope was still recording queries event though I had set it to stop recording. Using call tracing I found out that Laravel\Telescope\Watchers\QueryWatcher::recordQuery was still being called and using significant time. Fast forward to the debugger, and I found out that Telescope was somehow enabled again. A model in our seeder was dispatching a job that was executed synchronously. This triggered the following event listener in Telescope, which set Telescope to start recording again.

$app['events']->listen(JobProcessing::class, function () {
static::startRecording();
static::$processingJobs[] = true;
});

I do not think this behaviour is how it should work. It seems a bit odd that even though I tell Telescope to stop recording, due to a listener it starts recording again.

I've set up an example repository in a new Laravel project that shows the bug at https://github.com/erikgaal/telescope-recording-bug-example. I've also added a test that confirms the wrong behaviour.

https://github.com/erikgaal/telescope-recording-bug-example/blob/7d0812e2bbb4e63b9ae090282b0d4edda9519fd8/tests/Unit/ExampleTest.php#L17-L28

@ristlin
Copy link

ristlin commented Sep 11, 2019

I've run into a similar issue that eventually breaks tests as the watcher exhausts the allotted memory.

I personally don't see a need to have Telescope active during tests, so I've added the following to my phpunit.xml

<env name="TELESCOPE_ENABLED" value="false"/>

@nolanpro
Copy link

Thanks for this. If anyone was wondering why telescope was logging its own events, it might be your middleware is firing a sync event, as was our case. Then logging doesn't get turned off when the telescope page loads. The PR should fix it.

@robertvansteen
Copy link

@themsaid any plans to cut a new release that includes the fix for this? (#720)

@taylorotwell
Copy link
Member

Looks like this was fixed by a PR and has since been released.

@erikgaal
Copy link
Contributor Author

erikgaal commented Dec 6, 2019

Thanks for the release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants