Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Javascript Async Error Handling

ASecurity

Reviews and refactors asynchronous JavaScript error handling so Promise-based code avoids swallowed failures, unhandled rejections, unclear fallback behavior, and weak failure contracts.

4 stars
0 votes
0 copies
0 views
Added 10/2/2026
developmentjavascripttypescriptgojavanodeapifrontend

Works with

cliapi

Security Analysis

A100/100

Scanned 10/2/2026

$npx -y skills add janpereira-dev/ngAutoPilot --skill javascript--async-error-handling --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Javascript Async Error Handling?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Javascript  Async Error Handling
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/janpereira-dev-javascript-async-error-handling/badge)](https://www.skillsdirectory.com/skills/janpereira-dev-javascript-async-error-handling)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
id: javascript.async-error-handling
name: JavaScript Async Error Handling
description: >
  Reviews and refactors asynchronous JavaScript error handling so Promise-based code avoids swallowed failures, unhandled rejections, unclear fallback behavior, and weak failure contracts.
stack:
  - JavaScript
  - TypeScript
category: javascript
status: stable
version: 0.10.0
owner: NgAutoPilot
triggers:
  - async error handling
  - promise errors
  - unhandled promise rejection
  - async await catch
  - retry logic
  - fallback behavior
  - promise chains
  - async loops
compatibility:
  runtime:
    browser: true
    node: true
---

# JavaScript Async Error Handling

## Purpose

Use this skill to review, refactor, or implement safe error handling for asynchronous JavaScript code.

The goal is to prevent swallowed errors, unhandled promise rejections, duplicated catch blocks, unclear control flow, and unsafe fallback behavior.

This skill applies to plain JavaScript, TypeScript, Node.js, browser code, frontend services, API clients, scripts, and test utilities.

## When to Use

Use this skill when the task involves:

- `async` / `await`
- Promises
- `try` / `catch`
- `.then()` / `.catch()` chains
- API request error handling
- retry logic
- fallback values
- error propagation
- unhandled promise rejection warnings
- async code inside loops, callbacks, or event handlers

## When Not to Use

Do not use this skill when:

- the task is only about synchronous validation
- the problem belongs specifically to RxJS Observable error handling
- the task is only about HTTP status mapping in a framework-specific interceptor
- the code already has a domain-level error strategy and the request does not ask to change it
- the change would hide business errors behind generic fallbacks

## Do

Identify every async boundary involved in the requested change:

- public async functions
- event handlers
- API calls
- service methods
- promise chains
- dynamic imports
- file/network operations
- timers
- task queues
- test setup and teardown

Choose one explicit error contract per boundary:

- throw or reject when the caller must handle the failure
- return a typed result object when failure is part of normal flow
- return a fallback only when the fallback is correct and safe
- log and rethrow when the failure must be observable upstream

Prefer `async` / `await` for imperative flows:

```js
async function loadUser(userId) {
  try {
    return await userApi.getUser(userId);
  } catch (error) {
    throw new Error("Unable to load user", { cause: error });
  }
}
```

Never swallow errors silently:

```js
try {
  await saveData(data);
} catch (error) {
  logger.warn("Save failed", error);
  throw error;
}
```

Preserve stack and context when wrapping errors.

Avoid catch-all fallbacks unless empty data is semantically valid.

Handle parallel async flows intentionally:

- `Promise.all` for all-or-nothing work
- `Promise.allSettled` for valid partial success

Avoid floating promises unless intentionally fire-and-forget:

```js
void saveAuditLog(payload).catch((error) => {
  logger.warn("Audit log failed", error);
});
```

Use `for...of` with `await` for sequential async loops and `Promise.all` for parallel loops.

Test failure paths:

- rejected promise
- thrown async error
- fallback branch
- retry exhaustion
- partial success
- error propagation

## Do Not

Avoid empty catch blocks.

Avoid returning fake success from failed async work.

Avoid `forEach` with async callbacks.

Avoid unhandled promise rejections.

Avoid `Promise.allSettled` when fail-fast behavior is required.

Avoid retries without backoff or limits.

Avoid masking authentication or authorization failures as empty data.

## Review Checklist

- [ ] Every Promise is awaited, returned, or explicitly handled.
- [ ] Every catch block either recovers safely or rethrows.
- [ ] Fallback values are semantically valid.
- [ ] User-facing errors are separated from technical errors.
- [ ] Failure paths are tested.
- [ ] No unrelated async refactor was introduced.

## Expected Output

1. Identify async boundaries.
2. Choose a clear error contract.
3. Preserve stack and context.
4. Avoid swallowed or floating failures.
5. Add or update tests for success and failure paths.

Attribution

janpereira-devjanpereira-dev
View sourceSee grades on GitHubMore from janpereira-dev →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Clean Code

Pragmatic coding standards - concise, direct, no over-engineering, no unnecessary comments

304955 votes

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

286712 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2222 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Writing Plans

Use when you have a spec or requirements for a multi-step task, before touching code

2927051 votes
View all in development →