Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix: Remove incorrect await in sales utils (issue #6424)#6466

Merged
munkhsaikhan merged 1 commit intoerxes:mainfrom
belloibrahv:fix-await-issue-6424
Oct 12, 2025
Merged

Fix: Remove incorrect await in sales utils (issue #6424)#6466
munkhsaikhan merged 1 commit intoerxes:mainfrom
belloibrahv:fix-await-issue-6424

Conversation

@belloibrahv
Copy link
Contributor

@belloibrahv belloibrahv commented Oct 11, 2025

What

Removes incorrect await keyword used with a non-Promise returning function in backend/plugins/sales_api/src/modules/sales/utils.ts.

Why

Fixes issue #6424 - The getExtraFields function parameter is defined as a synchronous function that returns a plain object, not a Promise. Using await on it causes a TypeScript/ESLint error and is semantically incorrect.

How

  • Removed the await keyword from line 705 where getExtraFields(item) is called
  • The function signature shows getExtraFields?: (item: any) => { [key: string]: any } which returns a plain object synchronously, so no await is needed

Testing

  • Verified no new linting errors were introduced
  • Confirmed the file passes ESLint checks
  • The change is a simple removal of an unnecessary await keyword, which resolves the type error without affecting functionality

Related Issue: #6424


Important

Remove unnecessary await from synchronous getExtraFields(item) call in getItemList() in utils.ts.

  • Behavior:
    • Removed await from getExtraFields(item) call in getItemList() in utils.ts.
    • getExtraFields is a synchronous function returning a plain object, not a Promise.
  • Testing:
    • Verified no new linting errors.
    • Confirmed ESLint checks pass after change.

This description was created by Ellipsis for 59d2638. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed intermittent delays and missing data when displaying extra item details in Sales lists, ensuring consistent rendering and fewer timeouts.
  • Refactor
    • Optimized how optional extra fields are combined with items to avoid unnecessary blocking, improving responsiveness when loading large lists or slow auxiliary data sources.

@sourcery-ai
Copy link

sourcery-ai bot commented Oct 11, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Removed incorrect use of the await keyword when calling the synchronous getExtraFields function in sales utils, resolving TypeScript/ESLint errors without altering functionality.

Class diagram for getItemList and getExtraFields usage update

classDiagram
    class getItemList {
        <<async>>
        +getItemList(items, getExtraFields?)
    }
    class getExtraFields {
        <<optional>>
        +getExtraFields(item) { [key: string]: any }
    }
    getItemList --> "optional" getExtraFields: calls
Loading

File-Level Changes

Change Details Files
Removed unnecessary awaiting of a synchronous helper
  • Deleted await before getExtraFields(item)
  • Adjusted code to spread the synchronous return value directly
  • Ran ESLint to confirm no new lint errors
backend/plugins/sales_api/src/modules/sales/utils.ts

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link

coderabbitai bot commented Oct 11, 2025

Walkthrough

A change in getItemList within sales utils replaces an awaited call to getExtraFields(item) with a direct, non-awaited spread of getExtraFields(item), altering control flow when getExtraFields is asynchronous.

Changes

Cohort / File(s) Summary of Changes
Sales utils control-flow
backend/plugins/sales_api/src/modules/sales/utils.ts
Replaced awaited spreading of await getExtraFields(item) with direct spread of getExtraFields(item), affecting behavior when getExtraFields returns a Promise.

Sequence Diagram(s)

sequenceDiagram
    participant C as Caller
    participant U as getItemList
    participant E as getExtraFields

    Note over U: Previous behavior (await)
    C->>U: getItemList(items, getExtraFields)
    U->>E: getExtraFields(item)
    E-->>U: extraFields (resolved)
    U-->>C: item {...extraFields}

    break Current behavior (no await)
    C->>U: getItemList(items, getExtraFields)
    U->>E: getExtraFields(item)
    E-->>U: Promise<extraFields>
    U-->>C: item {...Promise}<br/>(Promise spread attempted)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit taps code with a careful ear,
One await hops off—now timing’s not clear.
Promises peek from the hedgerow’s shade,
Fields may sprout before they’re fully made.
I twitch my nose, add tests to see—
Will carrots resolve, or race past me? 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly and concisely describes the primary change—removing an incorrect await in the sales utils module—and references the relevant issue number, avoiding extraneous details or vague language.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 43416a5 and 59d2638.

📒 Files selected for processing (1)
  • backend/plugins/sales_api/src/modules/sales/utils.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx}: Write concise, technical TypeScript code
Use functional and declarative programming patterns; avoid classes
Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError)
Avoid console logs
Always use absolute paths for imports
Use TypeScript for all code (no .js/.jsx)
Prefer interfaces over types for object shapes
Avoid enums; use maps instead
Use the function keyword for pure functions
Avoid unnecessary curly braces in simple conditionals; use concise syntax

Files:

  • backend/plugins/sales_api/src/modules/sales/utils.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Sourcery review
🔇 Additional comments (1)
backend/plugins/sales_api/src/modules/sales/utils.ts (1)

705-706: No asynchronous getExtraFields definitions found
Scan for async getExtraFields returned no matches; dropping await is safe.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed everything up to 59d2638 in 17 seconds. Click for details.
  • Reviewed 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. backend/plugins/sales_api/src/modules/sales/utils.ts:705
  • Draft comment:
    Good fix: removing 'await' is correct since getExtraFields is synchronous. Make sure to update the usage if getExtraFields ever becomes async.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is informative and suggests a future action if the function changes, which is not actionable for the current PR. It doesn't provide a specific code suggestion or ask for a test to be written. It also doesn't point out a potential issue with the current code.

Workflow ID: wflow_PFmgFjkvlxc5JS3t

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@sonarqubecloud
Copy link

@belloibrahv
Copy link
Contributor Author

@Amura7 @maxnowack @munkhorgil @batnasan , kindly help me to review my PR when you have time, Thank You

@munkhsaikhan munkhsaikhan merged commit 7283d53 into erxes:main Oct 12, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments