razorpay / razorpay/razorpay-node

Promise rejection without error in `instance.orders.create()`

Open
#385 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
243
Forks
128
PR merge metrics
No merged PRs in 30d

Description

Steps to reproduce the behavior
try {
        const response = await razorpay.orders.create({
          amount: amount * 100,
          currency: "INR",
        });
        return {
          amount: response.amount,
          currency: response.currency,
          orderId: response.id,
        };
      } catch (e) {
        console.log(e);
        throw new TRPCError({
          code: "INTERNAL_SERVER_ERROR",
        });
      }
  `(node:15211) Warning: a promise was rejected with a non-error: [object Object]`
  Logging the error returns `{ statusCode: undefined, error: undefined }`.
Expected behavior

Should return the error if there is any.

Actual behavior

Sometimes the promise resolves itself without any error and sometimes it doesn't.

Code snippets

No response

Node version

v20.8.0

Library version

razorpay 2.9.2

Additional Information

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the instance.orders.create() entry point and reproduce the behavior with Node v20.8.0 and razorpay 2.9.2, checking both resolved and rejected calls. Done means failures consistently reject with an error containing the available statusCode and error details instead of a non-error object or an apparent success.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.