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

[EmailPlugin] Cannot read properties of undefined (reading 'headers') in production #2872

Closed
casperiv0 opened this issue May 31, 2024 · 2 comments
Assignees
Labels
type: bug 🐛 Something isn't working

Comments

@casperiv0
Copy link
Contributor

Describe the bug
When handling incoming orders from Mollie in production, we're getting the following error when we want to send a order success/confirmation email:

...
[MolliePlugin] Processing status 'paid' for order XXX for channel ...
[MolliePlugin] Payment for order GKHH3SWCTSZSSB2A with amount XXX created with state 'Settled'
error 5/31/24, 5:14 AM - [EmailPlugin] Cannot read properties of undefined (reading 'headers')
TypeError: Cannot read properties of undefined (reading 'headers')
  at ctx (/usr/src/app/node_modules/@vendure/asset-server-plugin/lib/src/common.js:10:44)
  at S3AssetStorageStrategy.toAbsoluteUrlFn [as toAbsoluteUrl] (/usr/src/app/node_modules/@vendure/asset-server-plugin/lib/src/s3-asset-storage-strategy.js:116:28)
  at transformOrderLineAssetUrls (/usr/src/app/node_modules/@vendure/email-plugin/lib/src/handler/default-email-handlers.js:78:46)
  at EmailEventHandlerWithAsyncData._loadDataFn (/usr/src/app/dist/src/plugins/email/handlers.js:25:56)
  at EmailEventHandlerWithAsyncData.handle (/usr/src/app/node_modules/@vendure/email-plugin/lib/src/handler/event-handler.js:299:41)
  at EmailPlugin.handleEvent (/usr/src/app/node_modules/@vendure/email-plugin/lib/src/plugin.js:354:42)
  at Object.next (/usr/src/app/node_modules/@vendure/email-plugin/lib/src/plugin.js:345:29)
  at ConsumerObserver.next (/usr/src/app/node_modules/rxjs/dist/cjs/internal/Subscriber.js:113:33)
  at Subscriber._next (/usr/src/app/node_modules/rxjs/dist/cjs/internal/Subscriber.js:80:26)
  at Subscriber.next (/usr/src/app/node_modules/rxjs/dist/cjs/internal/Subscriber.js:51:18) 

To Reproduce
Steps to reproduce the behavior:

  1. Complete an order
  2. Make sure you send an automated confirmation email
  3. Watch your logs
  4. See error

Expected behavior
It should send out the confirmation email and not throw the above error.

Environment (please complete the following information):

  • @vendure/core version: 2.2.4
  • Nodejs version: v20.14.0
  • Database (mysql/postgres etc): postgres

Additional context
Probably related to #1931, though, not in the mailbox sandbox. In the /mailbox sandbox it works fine!

@casperiv0 casperiv0 added the type: bug 🐛 Something isn't working label May 31, 2024
@michaelbromley
Copy link
Member

Thanks for the report. I think this is occurring because when the RequestContext object is created here, there is no request object associated with it.

We should be able to get the request object from the webhook method handler and pass it in. That should solve it.

@casperiv0
Copy link
Contributor Author

Thanks @michaelbromley for the quick bug fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants