magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Environment emulation nesting when sending invoice email

Open pumpe24 opened this issue 2 years ago • 9 comments

On Magento Open Source 2.4.4, $this->appEmulation->startEnvironmentEmulation($order->getStoreId(), Area::AREA_FRONTEND, true); is added to Magento\Sales\Model\Order\Email\Sender\InvoiceSender::send . While on this emulation there is a call to Magento\Payment\Helper\Data::getInfoBlockHtml where the emulation is started again.

This results in an error message main.ERROR: Environment emulation nesting is not allowed in system.log every time an invoice email is sent.

Preconditions (*)

  1. Magento Open Source 2.4.4

Steps to reproduce (*)

  1. send an invoice email

Expected result (*)

  1. it works, but system.log is flooded with the error message below

Actual result (*)

  1. system.log is flooded with main.ERROR: Environment emulation nesting is not allowed

pumpe24 avatar Jun 10 '22 08:06 pumpe24

Hi @pumpe24. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

m2-assistant[bot] avatar Jun 10 '22 08:06 m2-assistant[bot]

This was introduced at https://github.com/magento/magento2/commit/46b9d30e5c4b5a0499148968b8c708a7acbbf3da, which unfortunately missed the Magento\Sales\Model\Order\Email\Sender\OrderSender, so we can't just remove the call from getInfoBlockHtml.

kassner avatar Jun 13 '22 09:06 kassner

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

m2-assistant[bot] avatar Jun 15 '22 14:06 m2-assistant[bot]

Verified the issue on Magento 2.4-develop branch and the issue is reproducible. [2022-06-16T13:23:41.336531+00:00] main.ERROR: Environment emulation nesting is not allowed. [] [] is triggered in system.log on sending invoice email. Hence confirming this issue.

engcom-November avatar Jun 16 '22 13:06 engcom-November

@magento i am working on this

nisha-vaghela avatar Jun 17 '22 06:06 nisha-vaghela

can confirm this issue on 2.4.4 - not only on invoices but also on credit memos

simonmaass avatar Jun 29 '22 18:06 simonmaass

I am seeing this error in my system.log too since upgrading to Magento 2.4.4

main.ERROR: Environment emulation nesting is not allowed. [] []

What was the solution for this?

drinkingsouls avatar Jul 26 '22 11:07 drinkingsouls

Same here, also seeing it after upgrade to 2.4.4. I also think it's affecting cart integrity/behavior, as in, I place the order, it completes successfully, I see the error in the log, the cart shows it's empty, I got to a category page and the same product and suddenly the cart shows 2 items. If I proceed with the order and try to place it, I get an exception:

[2022-08-10T23:09:54.909522+00:00] main.ERROR: Magento2 v3.2.7: The cart details have changed. Please refresh the page and try again (1). [] [] [2022-08-10T23:09:54.909680+00:00] main.ERROR: Magento2 v3.2.7: #0 /home/michael/www/Farmacias-Roma-Magento/htdocs/vendor/stripe/module-payments/Model/PaymentMethod.php(180): StripeIntegration\Payments\Model\PaymentElement->updateFromOrder()

(I didn't paste the whole stack trace, too big)

If I refresh the page, I can place the order successfully, but the same issue happens again.

xtremevision avatar Aug 10 '22 23:08 xtremevision

We're having this issue with multiple shops as well.

reense avatar Aug 11 '22 12:08 reense

any solution on this issue?

kalalruturaj avatar Aug 17 '22 03:08 kalalruturaj

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-6611 is successfully created for this GitHub issue.

github-jira-sync-bot avatar Sep 01 '22 07:09 github-jira-sync-bot

:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

m2-assistant[bot] avatar Sep 01 '22 07:09 m2-assistant[bot]

Hello, having the same problem in magento 2.4.5.

Best regards, L Nunes

LeoNun avatar Sep 26 '22 18:09 LeoNun

This is also occurring when sending out shipment notification emails in Magento 2.4.4-p1.

jdubbya avatar Sep 26 '22 20:09 jdubbya

@nisha-vaghela are you working on this?

simonmaass avatar Sep 27 '22 08:09 simonmaass

seeing this problem as well

danielpugh avatar Oct 13 '22 11:10 danielpugh

Same here, possibly related to invoices being sent twice by cron (1 minute after each other)

i6media avatar Nov 03 '22 16:11 i6media

The issue still exists in 2.4.5-p1 (community edition) when sending an email after shipping an order.

MartynasKasp avatar Nov 11 '22 12:11 MartynasKasp

can confirm this for 2.4.5-p1

simonmaass avatar Nov 11 '22 13:11 simonmaass

Same issue on 2.4.4-p2

MikeDevs avatar Nov 23 '22 20:11 MikeDevs

Still exist on: Adobe Commerce ver. 2.4.5-p1

rofokken avatar Nov 28 '22 16:11 rofokken

Internal team started working on the issue.

glo23503 avatar Nov 30 '22 16:11 glo23503

Hi @glo23503! :wave: Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team command to join Contributors team.

m2-assistant[bot] avatar Nov 30 '22 16:11 m2-assistant[bot]

Hi @o-iegorov. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

    1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
    1. Verify that the issue is reproducible on 2.4-develop branch
      Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
      - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
      - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
    1. If the issue is not relevant or is not reproducible any more, feel free to close it.

m2-assistant[bot] avatar Nov 30 '22 16:11 m2-assistant[bot]

Hello, when will this PR be handled?

michi-z avatar Dec 19 '22 11:12 michi-z

@glo23503: this issue got closed without any comments, any idea why?

Might have been fixed by ACP2E-1341: [On-Premise] Merchant Informed Core Issue Magento 2.4.4 main.ERROR: Environment emulation nesting is not allowed, unfortunately I can't seem to find a clean merge commit

hostep avatar Jan 10 '23 20:01 hostep

Still present in 2.4.5-p1

MTheProgrammer avatar Jan 25 '23 06:01 MTheProgrammer

@kassner @hostep @simonmaass anyone aware of a workaround? We're running into this as well.

peterjaap avatar Jan 25 '23 19:01 peterjaap

@peterjaap hey peter! unfortunately not... currently living with the logspam... it doesnt seem to have an inpact on the actual functionality...

simonmaass avatar Jan 26 '23 11:01 simonmaass

Same here. Any update on why this is closed? Is there a patch we can add to fix it temporarily?

mv-ics avatar Jan 30 '23 07:01 mv-ics