An ECONNABORTED timeout sent me looking through the backend of Mama R's, an application I was building for a local bakery. I expected to find a problem with an API request or a database connection. Instead, the cause was a property name.
By then, the application had grown beyond its original order and inventory flows. Expense tracking and end-of-day reconciliation had added more data moving between screens, requests, and the backend. I could still explain each part on its own, but I was having a harder time remembering exactly what shape an object had at every boundary.
One property, several hours
The expense object was supposed to have an amount property. Somewhere along the way, the code used expense.cost instead.
That distinction was easy to miss while reading the surrounding logic. Both names made sense for an expense, and the request was far enough from where the object was created that I did not immediately connect the two. I spent time checking the Express backend, the request, and the database path because the timeout looked like a deeper problem.
Eventually I traced the value back through the flow and found that the property being read did not match the property on the object. The immediate fix was small: use expense.amount. Finding it took much longer because I had been debugging the layers around the data instead of checking the assumption I had made about the data itself.
I do not think this was a JavaScript problem in isolation. The same kind of mismatch can happen when a value crosses several boundaries and the expected shape is unclear. JavaScript let me build the first version quickly, but in this case I was relying on memory to keep the names consistent as the application grew.
The timeout was also only a symptom. A missing property does not automatically cause a database connection to hang, and a timeout can have many causes. What mattered here was that the wrong property sent me investigating a failure far away from the original assumption.
Adding a stronger contract
I migrated the project to TypeScript so I could describe the data shapes I expected and get feedback while working on them. For an expense, a small interface can make the intended property clear:
interface Expense {
description: string;
amount: number;
}
function getAmount(expense: Expense) {
return expense.amount;
}
With that type in place, writing expense.cost in the function would produce a type error: cost is not part of Expense. That feedback appears before I run the flow, close to the line where I made the wrong assumption. It does not remove the need to trace a request, but it can shorten the trip for this class of mistake.
The interface is a description used during development, not a check performed on every value arriving from a request. If an API returns unexpected data, declaring it to be an Expense does not make it one. Data from outside the application still needs validation at runtime, and the code still needs to handle API failures and database issues.
The useful change was making the expected shape visible where I worked with it. Instead of remembering whether the property was called cost or amount, I could check the type and let the editor point out a mismatch.
Less guessing
The benefit showed up in ordinary edits too. When I returned to an expense flow after working on another part of the application, the editor could show the available properties and their expected types. That was a helpful starting point, especially when the object passed through several functions.
Refactoring became easier to reason about for the same reason. If I changed a property on a shared type, TypeScript could point me toward typed code that still expected the old name. I still had to inspect the affected paths and test the behavior, but I had a clearer list of places to revisit.
It also made boundaries easier to think about: what does this function expect, what does it return, and where does untrusted data enter? Writing down those expectations did not settle every question, but it made assumptions easier to find and challenge.
The original fix was one property name. The lesson was about how much work had gone into finding it. As a system grows, relying on memory and implicit object shapes gets expensive. Good types do not replace runtime validation or testing, but they can make many mistakes much harder to miss.