@naturalcycles/datastore-lib 4.18.2 → 4.18.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -503,11 +503,14 @@ export class DatastoreDB extends BaseCommonDB {
503
503
  getRunQueryOptions(opt) {
504
504
  if (!opt.readAt)
505
505
  return {};
506
- return {
507
- // Datastore expects UnixTimestamp in milliseconds
508
- // Datastore requires the timestamp to be rounded to the whole minutes
509
- readTime: _round(opt.readAt, 60) * 1000,
510
- };
506
+ // Datastore expects UnixTimestamp in milliseconds
507
+ // Datastore requires the timestamp to be rounded to the whole minutes
508
+ const readTime = _round(opt.readAt, 60) * 1000;
509
+ if (readTime >= Date.now() - 1000) {
510
+ // To avoid the error of: The requested 'read_time' cannot be in the future
511
+ return {};
512
+ }
513
+ return { readTime };
511
514
  }
512
515
  }
513
516
  /**
@@ -177,7 +177,6 @@ export class DatastoreStreamReadable extends Readable {
177
177
  }, err);
178
178
  clearInterval(this.maxWaitInterval);
179
179
  this.destroy(err);
180
- return;
181
180
  }
182
181
  }
183
182
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/datastore-lib",
3
3
  "type": "module",
4
- "version": "4.18.2",
4
+ "version": "4.18.3",
5
5
  "description": "Opinionated library to work with Google Datastore, implements CommonDB",
6
6
  "dependencies": {
7
7
  "@google-cloud/datastore": "^10",
@@ -10,8 +10,8 @@
10
10
  "@naturalcycles/nodejs-lib": "^15"
11
11
  },
12
12
  "devDependencies": {
13
- "@types/node": "^24",
14
- "@naturalcycles/dev-lib": "20.12.10"
13
+ "@types/node": "^25",
14
+ "@naturalcycles/dev-lib": "18.4.2"
15
15
  },
16
16
  "exports": {
17
17
  ".": "./dist/index.js"
@@ -684,11 +684,15 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
684
684
  private getRunQueryOptions(opt: DatastoreDBReadOptions): RunQueryOptions {
685
685
  if (!opt.readAt) return {}
686
686
 
687
- return {
688
- // Datastore expects UnixTimestamp in milliseconds
689
- // Datastore requires the timestamp to be rounded to the whole minutes
690
- readTime: _round(opt.readAt, 60) * 1000,
687
+ // Datastore expects UnixTimestamp in milliseconds
688
+ // Datastore requires the timestamp to be rounded to the whole minutes
689
+ const readTime = _round(opt.readAt, 60) * 1000
690
+ if (readTime >= Date.now() - 1000) {
691
+ // To avoid the error of: The requested 'read_time' cannot be in the future
692
+ return {}
691
693
  }
694
+
695
+ return { readTime }
692
696
  }
693
697
  }
694
698
 
@@ -236,7 +236,6 @@ export class DatastoreStreamReadable<T = any> extends Readable implements Readab
236
236
  )
237
237
  clearInterval(this.maxWaitInterval)
238
238
  this.destroy(err as Error)
239
- return
240
239
  }
241
240
  }
242
241
  }