magespecialist / m2-MSP_DevTools

MageSpecialist DevTools for Magento2
221 stars 48 forks source link

Exception: Area code not set: Area code must be set before starting a session. #28

Open samuelecarpene opened 6 years ago

samuelecarpene commented 6 years ago

In production environment there is an error logged in exception log continuosly [2018-01-05 08:19:16] main.CRITICAL: Area code not set: Area code must be set before starting a session. {"exception":"[object] (Magento\Framework\Exception\SessionException(code: 0): Area code not set: Area code must be set before starting a session. at [website_path]/vendor/magento/framework/Session/SessionManager.php:175, Magento\Framework\Exception\LocalizedException(code: 0): Area code is not set at [website_path]/vendor/magento/framework/App/State.php:152)"} []

Preconditions

  1. Magento 2.2.2
  2. Ubuntu 16.04 Server
  3. PHP 7.0.22
  4. Mysql 5.7.19
  5. Magento installed/deployed with composer
  6. Magento in production mode

After some search i found that with this module disabled the problem is disappeared. How can i help you to identify the problem? If there is one...

phoenix128 commented 6 years ago

Hello @samuelecarpene , we were unable to reproduce this issue, can you provide additional information?

scottsb commented 6 years ago

We saw the same issue. I wasn't able to identify the pattern exactly, but it seemed to happen after a deploy. I'm not sure if it's the recompliation, static deploy or cache flush that would trigger it. After a few page loads it would seem to go away.

maqlec commented 6 years ago

I think I know where problem is. Your plugin is applied too deep on Zend Response guts where Magento area code is not set yet at least in production mode.

jefflenz commented 6 years ago

Same issue. Disabled this module and my store works now.

phoenix128 commented 6 years ago

Yes, the issue is confirmed on 2.2, we are working on that

magefan commented 6 years ago

the same issue with the extension when enabling maintenance mode.

phoenix128 commented 6 years ago

So sorry for making you wait for so long time. We had crazy time :) Thanks to @maqlec , this issue should be fixed.

cavalier79 commented 6 years ago

Does this issue have been solved? We also need it. Thanks!

jissereitsma commented 5 years ago

I had the same issue today: When the maintenance mode is enabled (in either Production Mode or Developer Mode) this error pops up, hiding the actual message that is given by the maintenance mode itself.

However, I don't think this necessarily needs a fix: In the Developer Mode, you don't need a maintenance mode - perhaps the docs of DevTools could just give a hint that the maintenance mode doesn't work well with the DevTools extension. And in the Production Mode, you should not use the DevTools extension anyway! The extension should be added to the require-dev section, not the require section.

jonasGossiaux commented 5 years ago

We also experience this issue on our development sites, we run 2.3.1. The issue occurs every time we perform a setup:upgrade or a cache clean. It also prevents us from accessing the admin side of our site.

VernonGrant commented 5 years ago

After you set bin/magento maintenance:enable in both development or production, this error is thrown.

stephen-larkbury commented 3 months ago

Any update on a fix for this :)