File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 1+ const TRANSACTION_TIMEOUT_MS = 10 * 1000 ;
2+
13// https://github.com/jakearchibald/safari-14-idb-fix/blob/582bbdc7230891113bfb5743391550cbf29d21f2/src/index.ts
24const idbReady = ( ) => {
35 const isSafari =
@@ -113,10 +115,20 @@ class Database {
113115 * @param {function } reject
114116 */
115117Database . setTransactionErrorHandler = ( transaction , reject ) => {
118+ const timeoutId = setTimeout ( ( ) => {
119+ reject ( new Error ( 'Transaction timed out' ) ) ;
120+ transaction . abort ( ) ;
121+ } , TRANSACTION_TIMEOUT_MS ) ;
122+
123+ transaction . oncomplete = ( ) => {
124+ clearTimeout ( timeoutId ) ;
125+ } ;
116126 transaction . onerror = ( e ) => {
127+ clearTimeout ( timeoutId ) ;
117128 reject ( new Error ( `Transaction error: ${ e . target . error } ` ) )
118129 } ;
119130 transaction . onabort = ( ) => {
131+ clearTimeout ( timeoutId ) ;
120132 reject ( new Error ( 'Transaction aborted' ) ) ;
121133 } ;
122134} ;
You can’t perform that action at this time.
0 commit comments