@@ -9,7 +9,7 @@ import type {
99} from '../../../@types/persisters/index.d.ts' ;
1010import { collValues } from '../../../common/coll.ts' ;
1111import { IdObj } from '../../../common/obj.ts' ;
12- import { startInterval , stopInterval } from '../../../common/other.ts' ;
12+ import { startInterval , stopInterval , tryCatch } from '../../../common/other.ts' ;
1313import { EMPTY_STRING } from '../../../common/strings.ts' ;
1414import {
1515 DATA_VERSION ,
@@ -62,23 +62,25 @@ export const createCustomSqlitePersister = <
6262 let interval : NodeJS . Timeout ;
6363
6464 const startPolling = ( ) =>
65- ( interval = startInterval ( async ( ) => {
66- try {
67- const [ { d, s, c} ] = ( await executeCommand (
68- SELECT +
69- // eslint-disable-next-line max-len
70- ` ${ DATA_VERSION } d,${ SCHEMA_VERSION } s,TOTAL_CHANGES() c FROM ${ PRAGMA } ${ DATA_VERSION } JOIN ${ PRAGMA } ${ SCHEMA_VERSION } ` ,
71- ) ) as [ IdObj < number > ] ;
72- if ( d != dataVersion || s != schemaVersion || c != totalChanges ) {
73- if ( dataVersion != null ) {
74- listener ( ) ;
65+ ( interval = startInterval (
66+ ( ) =>
67+ tryCatch ( async ( ) => {
68+ const [ { d, s, c} ] = ( await executeCommand (
69+ SELECT +
70+ // eslint-disable-next-line max-len
71+ ` ${ DATA_VERSION } d,${ SCHEMA_VERSION } s,TOTAL_CHANGES() c FROM ${ PRAGMA } ${ DATA_VERSION } JOIN ${ PRAGMA } ${ SCHEMA_VERSION } ` ,
72+ ) ) as [ IdObj < number > ] ;
73+ if ( d != dataVersion || s != schemaVersion || c != totalChanges ) {
74+ if ( dataVersion != null ) {
75+ listener ( ) ;
76+ }
77+ dataVersion = d ;
78+ schemaVersion = s ;
79+ totalChanges = c ;
7580 }
76- dataVersion = d ;
77- schemaVersion = s ;
78- totalChanges = c ;
79- }
80- } catch { }
81- } , autoLoadIntervalSeconds as number ) ) ;
81+ } ) ,
82+ autoLoadIntervalSeconds as number ,
83+ ) ) ;
8284
8385 const stopPolling = ( ) => {
8486 dataVersion = schemaVersion = totalChanges = null ;
0 commit comments