{"slug": "my-cursor-project-keeps-crashing-on-the-12th-line-of-a-loop", "title": "My Cursor project keeps crashing on the 12th line of a loop", "summary": "A developer using Cursor with Claude 3.5 Sonnet spent four hours debugging an intermittent React app crash caused by a race condition, which the AI repeatedly misdiagnosed due to outdated code context. The developer resolved the issue by manually adding console logs and pasting raw terminal output into the chat, prompting the AI to identify that a second API request was finishing before the first and overwriting state, leading to a three-line fix using AbortController. The developer also recommends using ChatGPT Projects as a knowledge base for coding style to reduce repetitive prompts.", "body_md": "# My Cursor project keeps crashing on the 12th line of a loop\n\n[Cursor](/en/tags/cursor/)with Claude 3.5 Sonnet, feeling smug because the AI was writing 80% of my boilerplate. Then I hit a wall.\n\nThe app would crash intermittently. No clear stack trace. Just a silent failure that left my local server hanging.\n\nI tried the usual \"Fix this\" prompt. Cursor looked at the file, told me the code looked fine, and suggested I check my network connection. I almost threw my keyboard.\n\n### The loop of hallucinations\n\nThe problem was a `useEffect`\n\nhook in a React component that was triggering an infinite re-render loop, but only when a specific API response came back in under 50ms.\n\nI kept feeding the error log to the AI. It kept giving me the same generic advice: \"Check your dependency array.\" I did. It was empty.\n\n`TypeError: Cannot read properties of undefined (reading 'map')`\n\nThat was the only clue. But the line it pointed to wasn't actually where the error was happening. It was a ghost in the machine. The AI was hallucinating the state of my variables because it was relying on an outdated index of my codebase.\n\nThis is where most people give up on AI coding and go back to manual debugging. I didn't. I realized I was treating Cursor like a magic wand instead of a tool.\n\n### Forcing the AI to actually see the bug\n\nI stopped asking it to \"fix\" the bug and started asking it to \"prove\" the state.\n\nI wrote a series of console logs to track the exact millisecond the state changed. I didn't let the AI write the logs—I wrote them manually so I knew exactly where they were. Then, I copied the raw terminal output and pasted it back into the chat.\n\nThe shift in results was instant. Instead of guessing, the AI saw the timestamps.\n\n\"Wait,\" the AI responded, \"the second request is finishing before the first one, but the first one is overwriting the state.\"\n\nThe fix was a simple `AbortController`\n\nto cancel previous requests. It took three lines of code. The previous four hours were spent fighting the AI's confidence rather than the bug itself.\n\nFor anyone struggling with similar loops, here are the Cursor debugging tips that actually saved my sanity:\n\n| Technique | Why it works | When to use it |\n\n| :--- | :--- | :--- |\n\n| **Log-Driven Prompting** | Feeds real-time data, not cached code | Intermittent bugs / Race conditions |\n\n| **File Pinning (@File)** | Forces the LLM to focus on the source of truth | Large projects with similar function names |\n\n| **Context Clearing** | Wipes the chat history to stop \"hallucination loops\" | When the AI keeps suggesting the same wrong fix |\n\n| **Pseudo-Code Verification** | Asks AI to explain logic in English before coding | Complex architectural changes |\n\n### Where [ChatGPT](/en/tags/chatgpt/) Projects usage fits in\n\nOnce I fixed the race condition, I realized I had a recurring problem. Every time I started a new feature, I had to explain my project's naming conventions, my preference for Tailwind utility classes, and the specific way I handled API errors to the AI.\n\nI started using ChatGPT Projects to act as a \"Knowledge Base\" for my coding style.\n\nUnlike a standard chat, I uploaded my `.eslintrc`\n\n, my global CSS variables, and a \"Style Guide\" markdown file to the Project's custom instructions. Now, when I move a snippet of code from Cursor over to ChatGPT for a high-level architectural review, the AI already knows that I hate using `any`\n\nand prefer `Zod`\n\nfor validation.\n\nIt turns the AI from a freelance contractor who doesn't know your codebase into a senior dev who has been on the team for three years.\n\nIf you're tired of repeating yourself, start a Project, dump your docs in there, and stop wasting tokens on introductory prompts.\n\n### Breaking the \"AI dependency\" trap\n\nThe wild part is that I almost let the tool make me a worse programmer. I was relying so much on the \"Tab\" autocomplete that I stopped reading the code I was shipping.\n\nI've found that the best way to actually grow is to engage with people who are hitting the same walls. That's why I spend a lot of time in the PromptCube community. It's not just about finding a \"golden prompt\" (those don't really exist), but about seeing how other devs are structuring their [AI Coding](/en/category/ai-coding/) workflows to avoid the exact burnout I felt last Thursday.\n\nSometimes you just need to see someone else's failed attempt to realize your approach is wrong.\n\n### Getting the most out of the workflow\n\nIf you want to stop the hallucination cycle, change your prompt structure.\n\nInstead of: *\"Why is this breaking?\"*\n\nTry: *\"Analyze the execution order of these three functions. List the state of variable X at each step. If you cannot determine the state, tell me which log I need to add.\"*\n\nIt forces the model to be analytical rather than predictive.\n\nFor those who want to see how these strategies look in practice, checking out some [Prompt Sharing](/en/category/prompts/) threads can give you a baseline for how to prompt for debugging versus prompting for feature generation. They are two entirely different skill sets.\n\nThe goal isn't to have the AI write the code; it's to use the AI to find the mistake you're too tired to see.\n\nIf you're looking for a place to refine these skills or want to see how others are integrating [MCP](/en/tags/mcp/) servers into their IDEs, the [PromptCube homepage](/en/) is a great starting point to dive into the deeper technical discussions.\n\nStop trusting the \"Fix\" button blindly. Write your own logs. Trust the data, not the LLM's confidence.\n\n[Next Connecting LLM agents to Slack or Teams usually feels like a →](/en/threads/5689/)\n\n[these AI tool field notes](https://tanyan888.com/), with plenty of directly applicable cases.\n\n## All Replies （0）\n\nNo replies yet — be the first!", "url": "https://wpnews.pro/news/my-cursor-project-keeps-crashing-on-the-12th-line-of-a-loop", "canonical_source": "https://promptcube3.com/en/threads/5704/", "published_at": "2026-08-09 18:54:27+00:00", "updated_at": "2026-08-09 19:20:42.656776+00:00", "lang": "en", "topics": ["developer-tools", "artificial-intelligence", "large-language-models"], "entities": ["Cursor", "Claude 3.5 Sonnet", "React", "ChatGPT Projects", "AbortController", "Tailwind", "Zod"], "alternates": {"html": "https://wpnews.pro/news/my-cursor-project-keeps-crashing-on-the-12th-line-of-a-loop", "markdown": "https://wpnews.pro/news/my-cursor-project-keeps-crashing-on-the-12th-line-of-a-loop.md", "text": "https://wpnews.pro/news/my-cursor-project-keeps-crashing-on-the-12th-line-of-a-loop.txt", "jsonld": "https://wpnews.pro/news/my-cursor-project-keeps-crashing-on-the-12th-line-of-a-loop.jsonld"}}