steamutils 1.1.21 → 1.1.23

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 -2
  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,15 +1525,14 @@ 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
- break
1526
1530
  } else if (response.status === 401) {
1527
1531
  console.log('Unauthorized')
1528
1532
  if (params.method.toUpperCase() === 'POST') {
1529
1533
  config.headers['Content-Type'] = config.headers['content-type'] = 'multipart/form-data'
1530
1534
  retry = 1
1531
1535
  }
1532
- break
1533
1536
  } else {
1534
1537
  console.log(response.status);
1535
1538
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.1.21",
3
+ "version": "1.1.23",
4
4
  "main":"index.js",
5
5
  "dependencies": {
6
6
  "axios": "^1.3.4",