Debug Async JavaScript Issues
AI prompt to identify and fix async JavaScript bugs, race conditions, and promise issues. Get step-by-step debugging guidance.
Prompt Template
Variables to Customize
[CODE_SNIPPET] The JavaScript code that's causing async issues
Example: async function fetchUserData(userId) { const user = fetch(`/api/users/${userId}`); const posts = fetch(`/api/users/${userId}/posts`); return { user: user.json(), posts: posts.json() }; }
[ISSUE_DESCRIPTION] Brief description of the async problem you're experiencing
Example: Data is returning as Promise objects instead of actual values, and sometimes the API calls seem to fail silently
[EXPECTED_BEHAVIOR] What you expect the code to do
Example: Function should return an object with user data and posts array
[ACTUAL_BEHAVIOR] What's actually happening
Example: Getting Promise objects instead of data, and inconsistent results
[RUNTIME_ENVIRONMENT] Where the code is running
Example: Node.js 18, Express server
[ERROR_MESSAGES] Any error messages you're seeing
Example: TypeError: Cannot read property 'name' of undefined (intermittent)
Example Output
Pro Tips for Best Results
- Always use await when calling the function that contains async operations
- Use Promise.all() instead of sequential awaits when operations can run concurrently
- Add comprehensive error handling with try-catch blocks around async operations
- Test with network throttling and offline scenarios to catch timing issues
- Use debugging tools like async stack traces in Chrome DevTools
Tags
Want 500+ Expert Prompts?
Get the Premium Prompt Pack — organized, tested, and ready to use.
Get it for $29Related Prompts You Might Like
Generate Docker Compose Configuration Files
You are an expert DevOps engineer specializing in containerization and Docker Compose. I need you to create a comprehens...
Migrate Database Between Versions
You are a senior database administrator tasked with creating a comprehensive migration plan for upgrading from [SOURCE_V...
Write Comprehensive Integration Tests
Act as a senior software testing engineer and write comprehensive integration tests for the following system. Your tests...
Convert JavaScript to TypeScript
You are an expert TypeScript developer tasked with converting JavaScript code to TypeScript. Please convert the followin...
Generate a Comprehensive Code Review Checklist
Act as a senior software engineer and create a comprehensive code review checklist for [PROGRAMMING_LANGUAGE] projects. ...
Write a Comprehensive Logging Configuration
You are an expert software engineer specializing in logging best practices. Create a comprehensive logging configuration...