oxc-project/oxc · warning · OxcDiagnostic

Promise in `Promise.{method_name}()` should not be awaited.

Error message

Promise in `Promise.{method_name}()` should not be awaited.

What it means

Diagnostic from the oxlint rule `unicorn/no-await-in-promise-methods` (category: correctness). It fires when an element of the array passed to `Promise.all()`, `Promise.allSettled()`, `Promise.any()`, or `Promise.race()` is itself an `await` expression. That inner await is usually a mistake: array elements are evaluated sequentially, so later elements (and their promise creation) wait on the awaited one, destroying the concurrency the combinator exists for. The rule ships an auto-fix that deletes the inner `await`.

Source

Thrown at crates/oxc_linter/src/rules/unicorn/no_await_in_promise_methods.rs:9

use oxc_ast::{AstKind, ast::Expression};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;

use crate::{AstNode, ast_util::is_method_call, context::LintContext, rule::Rule};

fn no_await_in_promise_methods_diagnostic(span: Span, method_name: &str) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!("Promise in `Promise.{method_name}()` should not be awaited."))
        .with_help("Remove the `await`")
        .with_label(span)
}

#[derive(Debug, Default, Clone)]
pub struct NoAwaitInPromiseMethods;

declare_oxc_lint!(
    /// ### What it does
    ///
    /// Disallow using `await` in `Promise` method parameters.
    ///
    /// ### Why is this bad?
    ///
    /// Using `await` on promises passed as arguments to `Promise.all()`,
    /// `Promise.allSettled()`, `Promise.any()`, or `Promise.race()` is likely a
    /// mistake.
    ///

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Delete the inner await so the promises are created concurrently: `Promise.all([fetchA(), fetchB()])` — `oxlint --fix` applies this automatically
  2. If the calls genuinely must run sequentially, drop the combinator and await them one by one
  3. For a deliberate case, suppress with `// oxlint-disable-next-line unicorn/no-await-in-promise-methods`

Example fix

// before
Promise.all([await getUser(), getPosts()]);

// after
Promise.all([getUser(), getPosts()]);
Defensive patterns

Strategy: validation

Validate before calling

# find offenders before enabling the rule
rg -n 'Promise\.(all|allSettled|any|race)\([^)]*await' src/

Prevention

When it happens

Trigger: A call to `Promise.all`/`allSettled`/`any`/`race` with exactly one array-literal argument, where an element is an await expression: `Promise.all([await promise, anotherPromise])`, `Promise.race([await a])`, `Promise.all([...foo, await p1, await p2])`. Sequence elements like `[(await p, 0)]` are not flagged.

Common situations: Refactoring sequential awaits into Promise.all and leaving the awaits inside the array; copy-pasting an awaited call into a combinator; enabling the unicorn preset and seeing correctness-category failures on existing async code.

Related errors


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/afa74784d54a8897. Report an issue: GitHub.