FP on javascript:S4123 (regression)

  • What language is this for? Javascript
  • Which rule? javascript:S4123
  • Why do you believe it’s a false-positive/false-negative? Regresion (see below)
  • Are you using
    • SonarQube Cloud? No
    • SonarQube Server / Community Build - which version? v25.12.0.117093
    • SonarQube for IDE - which IDE/version? 4.38.1
      • in connected mode with SonarQube Server / Community Build or SonarQube Cloud? Yes
  • How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
await methodName(param1name); // HERE

async function methodName(param1name) {
   ...
}

This seems to be a regression. It’s failing to allow “await” for functions with “async”

Previous comment

Update:

It seems to not necessarily be a False Positive.
SonarQube seems to also take into consideration the jsdoc. Below is a more complete reproducer:

await methodName(param1name); // HERE

/**
 *
 * @returns {string[]} List....
 */
async function methodName(param1name) {
   ...
}

However, after including the tag @async in the documentation, the warning disappears.

await methodName(param1name);

/**
 *
 * @async
 * @returns {string[]} List....
 */
async function methodName(param1name) {
   ...
}

I’d be nice if this is also explained in the warning (or the description of the rule).

Should I close this topic and create a new one with the improvement, or can this one be reused?

Thanks!

Ignore my last message. The warning appeared again (there was probably some delay analyzing the file).

Hi,

Are you saying you’re no longer thinking there’s a regression?

 
Thx,
Ann

Hello, Ann

Happy new Year!

It is still a regression. It fails with @async, too

1 Like

Hi,

Thanks!

This is flagged for the language experts.

 
Ann

1 Like

Hello @gian1200,

can you please share the full debug logs from the analysis? I cannot reproduce this. Using your snippet I see no raised issues.

Cheers!

1 Like

Hello, Victor

Do you have any guide to extract those logs?
In the meantime,please use this snippet. This should work:

File: “src/app/regression.mjs”

const aNumber = 1;

await methodName(aNumber);

/**
 * This is a method
 * @param {number} param1name this is a parameter
 * @async
 * @returns {string[]} List....
 */
async function methodName(param1name) {
	return [param1name];
}
Logs from Sonarqube for IDE
2026-01-09 08:29:54.656 [info] [Info - 08:29:54.654] [sonarlint : sonarlint-analysis-scheduler] Starting analysis with configuration: [

baseDir: c:\<redacted project path>

extraProperties: {sonar.cfamily.compile-commands=, sonar.js.internal.bundlePath=c:\Users\<redacted user>\.vscode\extensions\sonarsource.sonarlint-vscode-4.39.0-win32-x64\eslint-bridge}

activeRules: [13 kubernetes, 268 python, 430 cpp, 27 css, 189 c, 22 go, 264 ipython, 30 secrets, 331 javascript, 15 docker, 501 java, 50 Web, 15 xml, 299 csharpsquid, 167 php, 7 terraform, 344 typescript, 18 azureresourcemanager, 7 cloudformation]

inputFiles: [

file:///c:/<redacted project path>/src/app/regression.mjs (UTF-8) [js]

]

]

2026-01-09 08:29:54.834 [info] [Info - 08:29:54.833] [sonarlint : sonarlint-analysis-scheduler] Index files

2026-01-09 08:29:54.835 [info] [Info - 08:29:54.833] [sonarlint : Report about progress of file indexation] 1 file indexed

2026-01-09 08:29:54.928 [info] [Info - 08:29:54.927] [org.reflections.Reflections : sonarlint-analysis-scheduler] Reflections took 18 ms to scan 1 urls, producing 24 keys and 257 values

2026-01-09 08:29:54.944 [info] [Info - 08:29:54.942] [org.sonar.iac.common.extension.IacSensor : sonarlint-analysis-scheduler] There are no files to be analyzed for the Java language

2026-01-09 08:29:54.944 [info] [Info - 08:29:54.943] [org.sonar.iac.common.extension.IacSensor : sonarlint-analysis-scheduler] There are no files to be analyzed for the Docker language

2026-01-09 08:29:54.945 [info] [Warn - 08:29:54.943] [sonarlint : sonarlint-analysis-scheduler] No workDir in SonarLint

2026-01-09 08:29:55.230 [info] [Info - 08:29:55.229] [org.sonar.plugins.javascript.bridge.BridgeServerImpl : nodejs-stream-consumer] Using generated tsconfig.json file C:\Users\<redacted>\AppData\Local\Temp\tsconfig-0SUJX5.json

2026-01-09 08:29:59.390 [info] [Info - 08:29:59.388] [org.sonar.plugins.javascript.bridge.BridgeServerImpl : nodejs-stream-consumer] Found 1 tsconfig.json file(s): [C:\Users\<redacted>\AppData\Local\Temp\tsconfig-0SUJX5.json]

2026-01-09 08:29:59.391 [info] [Info - 08:29:59.389] [org.sonar.plugins.javascript.bridge.BridgeServerImpl : nodejs-stream-consumer] 1 source file to be analyzed

2026-01-09 08:29:59.391 [info] [Info - 08:29:59.389] [org.sonar.plugins.javascript.bridge.BridgeServerImpl : nodejs-stream-consumer] Using tsConfig C:\Users\<redacted>\AppData\Local\Temp\tsconfig-0SUJX5.json for file source file c:/<redacted project path>/src/app/regression.mjs (0/1 tsconfigs not yet checked)

2026-01-09 08:29:59.391 [info] [Info - 08:29:59.389] [org.sonar.plugins.javascript.bridge.BridgeServerImpl : nodejs-stream-consumer] 1/1 source file has been analyzed

2026-01-09 08:29:59.394 [info] [Info - 08:29:59.392] [org.sonar.plugins.javascript.analysis.cache.CacheReporter : sonarlint-analysis-scheduler] Hit the cache for 0 out of 1

2026-01-09 08:29:59.394 [info] [Info - 08:29:59.392] [org.sonar.plugins.javascript.analysis.cache.CacheReporter : sonarlint-analysis-scheduler] Miss the cache for 1 out of 1: RUNTIME_API_INCOMPATIBLE [1/1]

2026-01-09 08:29:59.405 [info] [Info - 08:29:59.401] [sonarlint : sonarlint-analysis-scheduler] Starting analysis with configuration: [

baseDir: c:\<redacted project path>

extraProperties: {sonar.cfamily.compile-commands=, sonar.js.internal.bundlePath=c:\Users\<redacted user>\.vscode\extensions\sonarsource.sonarlint-vscode-4.39.0-win32-x64\eslint-bridge}

activeRules: [13 kubernetes, 268 python, 430 cpp, 27 css, 189 c, 22 go, 264 ipython, 30 secrets, 331 javascript, 15 docker, 501 java, 50 Web, 15 xml, 299 csharpsquid, 167 php, 7 terraform, 344 typescript, 18 azureresourcemanager, 7 cloudformation]

inputFiles: [

file:///c:/<redacted project path>/src/app/regression.mjs (UTF-8) [js]

]

]

2026-01-09 08:29:59.554 [info] [Info - 08:29:59.553] [sonarlint : sonarlint-analysis-scheduler] Index files

2026-01-09 08:29:59.555 [info] [Info - 08:29:59.553] [sonarlint : Report about progress of file indexation] 1 file indexed

2026-01-09 08:29:59.637 [info] [Info - 08:29:59.635] [org.reflections.Reflections : sonarlint-analysis-scheduler] Reflections took 20 ms to scan 1 urls, producing 24 keys and 257 values

2026-01-09 08:29:59.646 [info] [Info - 08:29:59.645] [org.sonar.iac.common.extension.IacSensor : sonarlint-analysis-scheduler] There are no files to be analyzed for the Java language

2026-01-09 08:29:59.646 [info] [Info - 08:29:59.645] [org.sonar.iac.common.extension.IacSensor : sonarlint-analysis-scheduler] There are no files to be analyzed for the Docker language

2026-01-09 08:29:59.647 [info] [Warn - 08:29:59.645] [sonarlint : sonarlint-analysis-scheduler] No workDir in SonarLint

2026-01-09 08:29:59.796 [info] [Info - 08:29:59.794] [org.sonar.plugins.javascript.bridge.BridgeServerImpl : nodejs-stream-consumer] Using generated tsconfig.json file C:\Users\<redacted>\AppData\Local\Temp\tsconfig-cJiI4p.json

2026-01-09 08:30:03.058 [info] [Info - 08:30:03.057] [org.sonar.plugins.javascript.bridge.BridgeServerImpl : nodejs-stream-consumer] Found 1 tsconfig.json file(s): [C:\Users\<redacted>\AppData\Local\Temp\tsconfig-cJiI4p.json]

2026-01-09 08:30:03.059 [info] [Info - 08:30:03.057] [org.sonar.plugins.javascript.bridge.BridgeServerImpl : nodejs-stream-consumer] 1 source file to be analyzed

2026-01-09 08:30:03.059 [info] [Info - 08:30:03.057] [org.sonar.plugins.javascript.bridge.BridgeServerImpl : nodejs-stream-consumer] Using tsConfig C:\Users\<redacted>\AppData\Local\Temp\tsconfig-cJiI4p.json for file source file c:/<redacted project path>/src/app/regression.mjs (0/1 tsconfigs not yet checked)

2026-01-09 08:30:03.059 [info] [Info - 08:30:03.057] [org.sonar.plugins.javascript.bridge.BridgeServerImpl : nodejs-stream-consumer] 1/1 source file has been analyzed

2026-01-09 08:30:03.060 [info] [Info - 08:30:03.058] [org.sonar.plugins.javascript.analysis.cache.CacheReporter : sonarlint-analysis-scheduler] Hit the cache for 0 out of 1

2026-01-09 08:30:03.064 [info] [Info - 08:30:03.060] [org.sonar.plugins.javascript.analysis.cache.CacheReporter : sonarlint-analysis-scheduler] Miss the cache for 1 out of 1: RUNTIME_API_INCOMPATIBLE [1/1]

2026-01-09 08:30:03.064 [info] [Info - 08:30:03.060] [org.sonar.plugins.javascript.analysis.CssRuleSensor : sonarlint-analysis-scheduler] No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.

2026-01-09 08:30:03.067 [info] [Info - 08:30:03.066] [org.sonar.plugins.common.TextAndSecretsSensor : sonarlint-analysis-scheduler] Available processors: 8

2026-01-09 08:30:03.067 [info] [Info - 08:30:03.066] [org.sonar.plugins.common.TextAndSecretsSensor : sonarlint-analysis-scheduler] Using 8 threads for analysis.

2026-01-09 08:30:03.068 [info] [Info - 08:30:03.066] [org.sonar.plugins.common.TextAndSecretsSensor : sonarlint-analysis-scheduler] Start fetching files for the text and secrets analysis

2026-01-09 08:30:03.068 [info] [Info - 08:30:03.066] [org.sonar.plugins.common.TextAndSecretsSensor : sonarlint-analysis-scheduler] Retrieving all except binary files

2026-01-09 08:30:03.069 [info] [Info - 08:30:03.066] [org.sonar.plugins.common.analyzer.Analyzer : sonarlint-analysis-scheduler] Starting the text and secrets analysis

2026-01-09 08:30:03.074 [info] [Info - 08:30:03.070] [org.sonar.plugins.common.MultiFileProgressReport : Progress of the text and secrets analysis] 1 source file to be analyzed for the text and secrets analysis

2026-01-09 08:30:03.078 [info] [Info - 08:30:03.076] [org.sonar.plugins.common.MultiFileProgressReport : Progress of the text and secrets analysis] 1/1 source file has been analyzed for the text and secrets analysis

2026-01-09 08:30:03.079 [info] [Info - 08:30:03.078] [sonarlint : sonarlint-analysis-scheduler] Analysis detected 1 issue and 0 Security Hotspots in 3677ms

Attaching screenshots from Sonarqube for IDE on VSCode in connected mode (it also appears on Server)

Hello @gian1200,

sorry for the late reply, finally I had the time to reproduce and this is what I found out: Typescript does not detect methodName to return a Promise. It seems the JSDoc @returns annotation has higher precedence than TypeScript’s inference from the async keyword. When you specify @returns {string[]}, TypeScript uses that type directly, ignoring that async should wrap it in a Promise.

There are two solutions:

  1. Remove @returns entirely (let TypeScript infer)
  2. Use @returns {Promise<string[]>} (explicit correct type)

I would recommend the second one, as @returns {string[]} is not strictly correct.

Hello, Victor

I do not use TypeScript. I use JavaScript, but your comment still applies.

After rereading the documentation, @async does not modify/re-define the return type.

I also agree with you, option 2 (explicit correct type) is better.

Thank you for your time, and sorry for the inconvenience.

1 Like

Hi @gian1200,

yes, I saw you are using Javascript. Sorry I was not very clear in my response. The issue is raised because we use TypeScript in the analyzer, and we rely on whatever the type checker is inferring from the code.

So I was just referring on why Sonar was raising the issue, not to your specific dev context.

Cheers!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.