Async operations return Promises
Why it matters
Callback-based async APIs are incompatible with async/await, require consumers to wrap calls in new Promise() to compose them, and produce inverted error-handling patterns compared to modern JavaScript. ISO 25010 interoperability degrades when your API cannot be composed with Promise.all, Promise.race, or async middleware chains. Callback-only APIs also make it harder to surface errors correctly — thrown errors inside callbacks are swallowed by the event loop if the callback doesn't explicitly handle them.
Severity rationale
Medium because callback-only APIs block `async/await` usage and complicate error propagation, but do not cause immediate failures — they require consumers to add boilerplate wrapping.
Remediation
Convert callback-based methods to async functions returning typed Promises.
// Before — callback pattern:
export function fetchData(
url: string,
callback: (err: Error | null, data?: ResponseData) => void
) { /* ... */ }
// After — Promise pattern:
export async function fetchData(url: string): Promise<ResponseData> {
const response = await fetch(url)
if (!response.ok) throw new ApiError('Request failed', response.status)
return response.json() as Promise<ResponseData>
}
If you need to maintain backward compatibility during a migration, add the Promise API alongside the callback API and deprecate the callback variant with a JSDoc @deprecated tag.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the SDK / Package Quality Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · compatibility.interoperability — Interoperability — Promise-based API composes with modern async/await toolchains
- iso-25010:2011 · maintainability.modifiability — Modifiability — callback APIs are harder to compose and migrate
Taxons
History
- 2026-04-18·v1.0.0·Initial import from sdk-package-quality·automated