steamutils 1.1.21 → 1.1.22

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.
Files changed (2) hide show
  1. package/index.js +5 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -19,6 +19,7 @@ import * as cherrio from "cheerio";
19
19
 
20
20
  const MAX_RETRY = 10
21
21
  let requestTimestamp = 0
22
+ let tooManyRequestTimestamp = 0
22
23
  export const MatchHistoryType = {
23
24
  matchhistoryscrimmage: 'matchhistoryscrimmage',
24
25
  matchhistorycompetitive: 'matchhistorycompetitive',
@@ -1510,6 +1511,9 @@ class SteamUser {
1510
1511
  while ((diff = (now = new Date().getTime()) - requestTimestamp) < 500) {
1511
1512
  await sleep(diff + 10)
1512
1513
  }
1514
+ while ((diff = (now = new Date().getTime()) - tooManyRequestTimestamp) < 30000) {
1515
+ await sleep(diff + 10)
1516
+ }
1513
1517
  requestTimestamp = now
1514
1518
  response = await axios.request(config)
1515
1519
 
@@ -1521,6 +1525,7 @@ class SteamUser {
1521
1525
  break
1522
1526
  } else if (response.status === 429) {
1523
1527
  console.log('Too Many Requests')
1528
+ tooManyRequestTimestamp = new Date().getTime()
1524
1529
  await sleep(30000)
1525
1530
  break
1526
1531
  } else if (response.status === 401) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.1.21",
3
+ "version": "1.1.22",
4
4
  "main":"index.js",
5
5
  "dependencies": {
6
6
  "axios": "^1.3.4",