File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,12 @@ async function fsyncDir(dirname: string): Promise<void> {
137137 await fs . close ( fd ) ;
138138}
139139
140+ function getCurrentErrorStack ( ) : string {
141+ const tmp = { message : "" } ;
142+ Error . captureStackTrace ( tmp ) ;
143+ return ( tmp as any ) . stack . split ( "\n" ) . slice ( 2 ) . join ( "\n" ) ;
144+ }
145+
140146export class JsonlDB < V extends unknown = unknown > {
141147 public constructor ( filename : string , options : JsonlDBOptions < V > = { } ) {
142148 this . validateOptions ( options ) ;
@@ -640,7 +646,13 @@ export class JsonlDB<V extends unknown = unknown> {
640646 filename : targetFilename ,
641647 done,
642648 } ) ;
643- return done ;
649+ const stack = getCurrentErrorStack ( ) ;
650+ try {
651+ await done ;
652+ } catch ( e : any ) {
653+ e . stack += "\n" + stack ;
654+ throw e ;
655+ }
644656 }
645657
646658 private needToCompressBySize ( ) : boolean {
@@ -864,7 +876,13 @@ export class JsonlDB<V extends unknown = unknown> {
864876 type : "compress" ,
865877 done,
866878 } ) ;
867- return done ;
879+ const stack = getCurrentErrorStack ( ) ;
880+ try {
881+ await done ;
882+ } catch ( e : any ) {
883+ e . stack += "\n" + stack ;
884+ throw e ;
885+ }
868886 }
869887
870888 /** Closes the DB and waits for all data to be written */
You can’t perform that action at this time.
0 commit comments