tezvyn:

Write an IndexedDB add function with transaction error handling

Source: developer.mozilla.orgintermediate

Tests IndexedDB request-transaction lifecycle and event-driven error propagation. Answers open a transaction, call add(), and wire onsuccess/onerror on the request plus onabort/onerror on the transaction. Red flag: ignoring onabort or duplicate-key throws.

This question tests whether you understand IndexedDB's two-level event model, where requests and transactions fail independently. A solid answer opens a readwrite transaction, gets the object store, calls add(), and wires onsuccess and onerror on the request while also listening for onabort and onerror on the transaction to catch quota or schema failures. It notes that add() throws immediately on duplicate keys. A red flag is a Promise wrapper that only awaits the request and ignores transaction.onabort, letting quota errors pass silently.

Read the original → developer.mozilla.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Write an IndexedDB add function with transaction error handling · Tezvyn