You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
When inserting data into an IndexedDB store with a unique index on multiple fields (e.g., a and b), the package throws a ConstraintError if a duplicate entry is attempted. While I can catch this error and handle it (e.g., updating non-unique fields), the package also throws an AbortError with no stack trace, making it difficult to debug and handle gracefully. This issue stems from the inability to customize event listeners like success, complete, error, and abort in the current implementation.
Describe the solution you'd like
I would like the ability to customize event listeners (success, complete, error, abort) in the idb package. Specifically:
Allow developers to override or extend these listeners to handle errors like ConstraintError and AbortError more gracefully.
Ensure that errors passed to the error and abort listeners are propagated correctly, including stack traces, so they can be debugged and handled effectively.
A temporary solution would be passing the error down from the "Event Listener" to the error function so that errors could be recognized and handled.
This would enable better error handling and recovery in scenarios like duplicate entries, where developers might want to update existing records instead of failing the transaction.
Relevant Code
Here are the relevant parts of the code where this issue arises:
promisifyRequest: This function handles the promise-based wrapping of IndexedDB requests but does not propagate errors from event listeners.
cacheDonePromiseForTransaction: This function caches the transaction's completion promise but does not provide a way to customize error handling.
The text was updated successfully, but these errors were encountered:
Shaghal
changed the title
Enable Graceful Handling of ConstraintError and AbortError in IndexedDB
Enable Graceful Handling of ConstraintError and AbortErrorJan 20, 2025
Is your feature request related to a problem? Please describe.
When inserting data into an IndexedDB store with a unique index on multiple fields (e.g., a and b), the package throws a ConstraintError if a duplicate entry is attempted. While I can catch this error and handle it (e.g., updating non-unique fields), the package also throws an AbortError with no stack trace, making it difficult to debug and handle gracefully. This issue stems from the inability to customize event listeners like success, complete, error, and abort in the current implementation.
Describe the solution you'd like
I would like the ability to customize event listeners (success, complete, error, abort) in the idb package. Specifically:
Allow developers to override or extend these listeners to handle errors like ConstraintError and AbortError more gracefully.
Ensure that errors passed to the error and abort listeners are propagated correctly, including stack traces, so they can be debugged and handled effectively.
A temporary solution would be passing the error down from the "Event Listener" to the error function so that errors could be recognized and handled.
This would enable better error handling and recovery in scenarios like duplicate entries, where developers might want to update existing records instead of failing the transaction.
Relevant Code
Here are the relevant parts of the code where this issue arises:
promisifyRequest: This function handles the promise-based wrapping of IndexedDB requests but does not propagate errors from event listeners.
cacheDonePromiseForTransaction: This function caches the transaction's completion promise but does not provide a way to customize error handling.
The text was updated successfully, but these errors were encountered: