vuestorefront / vue-storefront

Alokai is a Frontend as a Service solution that simplifies composable commerce. It connects all the technologies needed to build and deploy fast & scalable ecommerce frontends. It guides merchants to deliver exceptional customer experiences quickly and easily.
https://www.alokai.com
MIT License
10.63k stars 2.08k forks source link

[Bug]: Cannot set headers after they are sent to the client #6893

Open marc-arnoult opened 1 year ago

marc-arnoult commented 1 year ago

Describe the Bug

Hi after upgrading our dependencies to ~2.7 @vue-storefront/middleware and @vue-storefront/magento (1.0.0) we have this kind of errors on our testing environment : Cannot set headers after they are sent to the client.

Before that we were on @vue-storefront/middleware (2.5.4) It seem to be pretty random, hard to reproduce. But it will block any new request from the client ( add to cart etc... )

Kind regards,

Marc

Current behavior

We can't add any product to cart, or interact with the application when this error appear ( Status 400 on the front ).

Expected behavior

The customer should be able to continue is journey on our website without having this kind of errors.

Steps to reproduce

No response

What version of Vue Storefront are you using?

2.7.1

What version of Node.js are you using?

16.19.0

What browser (and version) are you using?

Chrome 111.0.5563.64

What operating system (and version) are you using?

macOS

Relevant log output

  |   | 2023-03-17 10:38:48 | at processTicksAndRejections (node:internal/process/task_queues:96:5) |  
  |   | 2023-03-17 10:38:48 | at runMicrotasks (<anonymous>) |  
  |   | 2023-03-17 10:38:48 | at node_modules/@vue-storefront/middleware/lib/index.cjs.js:172:17 |  
  |   | 2023-03-17 10:38:48 | at ServerResponse.send (node_modules/express/lib/response.js:162:21) |  
  |   | 2023-03-17 10:38:48 | at ServerResponse.json (node_modules/express/lib/response.js:278:15) |  
  |   | 2023-03-17 10:38:48 | at ServerResponse.send (node_modules/express/lib/response.js:174:12) |  
  |   | 2023-03-17 10:38:48 | at ServerResponse.header (node_modules/express/lib/response.js:794:10) |  
  |   | 2023-03-17 10:38:48 | at ServerResponse.setHeader (node:_http_outgoing:576:11) |  
  |   | 2023-03-17 10:38:48 | at new NodeError (node:internal/errors:371:5) |  
  |   | 2023-03-17 10:38:48 |   |  
  |   | 2023-03-17 10:38:48 | ERROR  Cannot set headers after they are sent to the client

Able to fix / change the documentation?

Code of Conduct

skirianov commented 1 year ago

Hi @marc-arnoult Dev Advocate Sergii here, so the only thing you did was to change to the middleware package am I right?

Is there any source code I could look at?