File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -752,12 +752,26 @@ class AbstractLevel extends EventEmitter {
752752
753753 const original = options
754754 const keyEncoding = this . keyEncoding ( options . keyEncoding )
755+ const snapshot = options . snapshot != null ? options . snapshot : null
755756
756757 options = rangeOptions ( options , keyEncoding )
757758 options . keyEncoding = keyEncoding . format
758759
759760 if ( options . limit !== 0 ) {
760- await this . _clear ( options )
761+ // Keep snapshot open during operation
762+ if ( snapshot !== null ) {
763+ snapshot . ref ( )
764+ }
765+
766+ try {
767+ await this . _clear ( options )
768+ } finally {
769+ // Release snapshot
770+ if ( snapshot !== null ) {
771+ snapshot . unref ( )
772+ }
773+ }
774+
761775 this . emit ( 'clear' , original )
762776 }
763777 }
You can’t perform that action at this time.
0 commit comments