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

Error after Stripe payment #2601

Closed
LWJerri opened this issue Nov 14, 2022 · 2 comments
Closed

Error after Stripe payment #2601

LWJerri opened this issue Nov 14, 2022 · 2 comments

Comments

@LWJerri
Copy link

LWJerri commented Nov 14, 2022

Bug report

Describe the bug

After some of my purchases, I get a 500 error for the /store/carts/cart_CART_ID/complete API endpoint.

System information

Medusa version (including plugins):

  • medusa-fulfillment-manual: ^1.1.31
  • medusa-payment-manual: ^1.0.16
  • medusa-payment-stripe: ^1.1.45 (Have problem with ^1.1.46)

Node.js version: v18.10.0
Database: PSQL v14.2
Operating system: WSL (Linux).
Browser (if relevant): Google Chrome.

Steps to reproduce the behavior

  1. Setup basic medusajs frontend, backend and admin panel.
  2. Setup Stripe payment.
  3. Try to buy a test item.
  4. See error.

Expected behavior

200 response for the query.

I talk about it in Medusa Community Discord server: https://discord.com/channels/876835651130097704/1041669823043731466

Screenshots

image

Code snippets

54.187.174.169 - - [14/Nov/2022:13:34:44 +0000] "POST /stripe/hooks HTTP/1.1" 200 2 "-" "Stripe/1.0 (+https://stripe.com/docs/webhooks)"
error:   could not serialize access due to concurrent update
QueryFailedError: could not serialize access due to concurrent update
    at QueryFailedError.TypeORMError [as constructor] (/home/lwjerri/medusa/medusa-store/node_modules/typeorm/error/TypeORMError.js:9:28)
    at new QueryFailedError (/home/lwjerri/medusa/medusa-store/node_modules/typeorm/error/QueryFailedError.js:13:28)
    at PostgresQueryRunner.<anonymous> (/home/lwjerri/medusa/medusa-store/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:281:31)
    at step (/home/lwjerri/medusa/medusa-store/node_modules/tslib/tslib.js:144:27)
    at Object.throw (/home/lwjerri/medusa/medusa-store/node_modules/tslib/tslib.js:125:57)
    at rejected (/home/lwjerri/medusa/medusa-store/node_modules/tslib/tslib.js:116:69)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  query: 'UPDATE "payment_session" SET "status" = $1, "updated_at" = CURRENT_TIMESTAMP WHERE "id" IN ($2) RETURNING "updated_at"',
  parameters: [ 'authorized', 'ps_01GHV5J3JWS21SAGTBG4YMYECG' ],
  driverError: error: could not serialize access due to concurrent update
      at Parser.parseErrorMessage (/home/lwjerri/medusa/medusa-store/node_modules/pg-protocol/dist/parser.js:287:98)
      at Parser.handlePacket (/home/lwjerri/medusa/medusa-store/node_modules/pg-protocol/dist/parser.js:126:29)
      at Parser.parse (/home/lwjerri/medusa/medusa-store/node_modules/pg-protocol/dist/parser.js:39:38)
      at Socket.<anonymous> (/home/lwjerri/medusa/medusa-store/node_modules/pg-protocol/dist/index.js:11:42)
      at Socket.emit (node:events:513:28)
      at Socket.emit (node:domain:489:12)
      at addChunk (node:internal/streams/readable:324:12)
      at readableAddChunk (node:internal/streams/readable:297:9)
      at Readable.push (node:internal/streams/readable:234:10)
      at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
    length: 116,
    severity: 'ERROR',
    code: '40001',
    detail: undefined,
    hint: undefined,
    position: undefined,
    internalPosition: undefined,
    internalQuery: undefined,
    where: undefined,
    schema: undefined,
    table: undefined,
    column: undefined,
    dataType: undefined,
    constraint: undefined,
    file: 'nodeModifyTable.c',
    line: '1842',
    routine: 'ExecUpdate'
  },
  length: 116,
  severity: 'ERROR',
  code: '40001',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'nodeModifyTable.c',
  line: '1842',
  routine: 'ExecUpdate'
}
::1 - - [14/Nov/2022:13:34:44 +0000] "POST /store/carts/cart_01GHV5A57HWNA632089HWKFP8R/complete HTTP/1.1" 500 86 "http://localhost:8000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
@olivermrbl
Copy link
Contributor

Issue is related to concurrent requests trying to complete the cart and it only happens when the webhook is enabled. We've added this one to our backlog with high priority. You can expect a fix EoW :)

@olivermrbl
Copy link
Contributor

Solved in 1.6.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants