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

Tracy always starts a session #356

Closed
jkufner opened this issue Mar 11, 2019 · 9 comments
Closed

Tracy always starts a session #356

jkufner opened this issue Mar 11, 2019 · 9 comments

Comments

@jkufner
Copy link

jkufner commented Mar 11, 2019

Version: 2.4.0+, introduced by 5c46e98

Bug Description

Tracy always starts a session because 5c46e98#diff-be100a67d872789dffa3bfba6144122dR89

Steps To Reproduce

Don't start a session, enable Tracy.

Expected Behavior

Session does not start.

Possible Solution

Remove the start() call from DI container and don't be lazy to check if there is a started session. Such a code don't belong to DI container anyway.

See 5c46e98#diff-be100a67d872789dffa3bfba6144122dR89

@jkufner jkufner changed the title Tracy always starts session Tracy always starts a session Mar 11, 2019
@dg
Copy link
Member

dg commented Mar 11, 2019

Can you send PR?

@jkufner
Copy link
Author

jkufner commented Mar 12, 2019

Maybe. It depends on how deep the session goes. I will give it a try.

@milo
Copy link
Member

milo commented Mar 19, 2019

@jkufner It starts in debug mode only, doesn't?

if ($this->debugMode) {
foreach ((array) $this->config['bar'] as $item) {
if (is_string($item) && substr($item, 0, 1) === '@') {
$item = new Nette\DI\Statement(['@' . $builder::THIS_CONTAINER, 'getService'], [substr($item, 1)]);
} elseif (is_string($item)) {
$item = new Nette\DI\Statement($item);
}
$initialize->addBody($builder->formatPhp(
'$this->getService(?)->addPanel(?);',
Nette\DI\Helpers::filterArguments([$this->prefix('bar'), $item])
));
}
if (!$this->cliMode && ($name = $builder->getByType(Nette\Http\Session::class))) {
$initialize->addBody('$this->getService(?)->start();', [$name]);
$initialize->addBody('Tracy\Debugger::dispatch();');
}
}

@jkufner
Copy link
Author

jkufner commented Mar 19, 2019

@milo Yes, the following line causes the issue:

$initialize->addBody('$this->getService(?)->start();', [$name]); 

@milo
Copy link
Member

milo commented Mar 20, 2019

@jkufner Sorry, my point is: Is it a problem to always start session in debug mode? Tracy "always" needs. Usually it is a session for developer on local machine.

@jkufner
Copy link
Author

jkufner commented Mar 20, 2019

@milo If there are no errors to report, then there is no reason to have a session stored and a cookie sent to a client. Tracy <2.4 behaves this way.

Always starting a session prevents us from implementing a state-less API and pollutes the server with useless sessions as every request creates a new session because non-browser clients ignore cookies.

@milo
Copy link
Member

milo commented Mar 20, 2019

@jkufner Your server does not run in a production mode?

@jkufner
Copy link
Author

jkufner commented Mar 20, 2019

@milo Of course not; it is a development server.

@forrest79
Copy link
Contributor

Hi, we have a similar problem and we would appriciate Tracy without session. I prepared PR - just a concept.

@dg dg closed this as completed in 8fd3f93 Dec 10, 2021
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

4 participants