Skip to content

Commit 2b7da8c

Browse files
committed
fix: 2min timeouts for all http reqs, 20min for kmz
1 parent 7e19634 commit 2b7da8c

File tree

5 files changed

+12
-23
lines changed

5 files changed

+12
-23
lines changed

commands/run.js

-17
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const os = require('os');
2828
const path = require('path');
2929
const promisify = require('util').promisify;
3030
const pug = require('pug');
31-
const rp = require('request-promise');
3231
const yaml = require('js-yaml');
3332
const {globalStats, MeasureUnit} = require('@opencensus/core');
3433

@@ -152,10 +151,6 @@ exports.builder = {
152151
boolean: true,
153152
desc: 'Use real fire names not hashtags',
154153
},
155-
archiveInciweb: {
156-
boolean: true,
157-
desc: 'Save InciWeb updates to web.archive.org',
158-
},
159154
emergingNew: {
160155
boolean: true,
161156
default: false,
@@ -649,18 +644,6 @@ exports.handler = (argv) => {
649644
const perimWebpage = argv.outputdir + '/img/WEB-PERIM-' + updateId + '.html';
650645
const mainWebpageUrl = 'http://localhost:8080/updates/img/WEB-INFO-' + updateId + '.html';
651646
const perimWebpageUrl = 'http://localhost:8080/updates/img/WEB-PERIM-' + updateId + '.html';
652-
if (inciWeb && argv.archiveInciweb) {
653-
const u = 'https://web.archive.org/save/https://inciweb.nwcg.gov/incident/' + inciWeb + '/';
654-
rp({uri: u, resolveWithFullResponse: true}).then((r) => {
655-
logger.info(' ~~ Archived to web.archive.org: %s', r.headers ? ('https://web.archive.org/' + r.headers['content-location']) : 'unknown');
656-
}).catch((err) => {
657-
logger.info(' ~~ ERROR Archiving to web.archive.org: ' + u);
658-
logger.info(err);
659-
if (argv.failOnError) {
660-
process.exit(13);
661-
}
662-
});
663-
}
664647
let rr = null;
665648
if (perim.length > 1 && argv.locations) {
666649
rr = await maprender.getMapBounds(perim, 1450 / 2, 1200 / 2, 15, cur.DailyAcres || 0);

lib/calfire.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,14 @@ Archived: https://web.archive.org/web/20190627202100/https://www.fire.ca.gov/con
113113
*/
114114

115115
// ua: user-agent
116-
exports.getFires = async function(ua) {
116+
exports.getFires = async function(ua, timeoutMs) {
117117
const firesDataOptions = {
118118
uri: 'https://www.fire.ca.gov/imapdata/mapdataactive.csv',
119119
qs: qs,
120120
headers: {
121121
'User-Agent': 'Request-Promise; ' + ua,
122122
},
123+
timeout: timeoutMs || 120000,
123124
json: false,
124125
};
125126
const provenance = util.createProvenance(firesDataOptions);
@@ -137,13 +138,14 @@ exports.getFires = async function(ua) {
137138
};
138139

139140

140-
exports.getFireDetail = async function(fire, ua) {
141+
exports.getFireDetail = async function(fire, ua, timeoutMs) {
141142
const firesDataOptions = {
142143
uri: fire.Link,
143144
qs: qs,
144145
headers: {
145146
'User-Agent': 'Request-Promise; ' + ua,
146147
},
148+
timeout: timeoutMs || 120000,
147149
json: false,
148150
};
149151
const provenance = util.createProvenance(firesDataOptions);

lib/geomac.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,14 @@ const qs = {
9999
};
100100

101101

102-
exports.getPerimeters = async function(ua, latest) {
102+
exports.getPerimeters = async function(ua, latest, timeoutMs) {
103103
const perimDataOptions = {
104104
uri: 'https://wildfire.cr.usgs.gov/ArcGIS/rest/services/geomac_dyn/MapServer/' + (latest ? '3' : '2') + '/query',
105105
qs: qs,
106106
headers: {
107107
'User-Agent': 'Request-Promise; ' + ua,
108108
},
109+
timeout: timeoutMs || 120000,
109110
json: true,
110111
};
111112
const provenance = util.createProvenance(perimDataOptions);
@@ -117,13 +118,14 @@ exports.getPerimeters = async function(ua, latest) {
117118
};
118119

119120

120-
exports.getFires = async function(ua) {
121+
exports.getFires = async function(ua, timeoutMs) {
121122
const firesDataOptions = {
122123
uri: 'https://wildfire.cr.usgs.gov/arcgis/rest/services/geomac_dyn/MapServer/0/query',
123124
qs: qs,
124125
headers: {
125126
'User-Agent': 'Request-Promise; ' + ua,
126127
},
128+
timeout: timeoutMs || 120000,
127129
json: true,
128130
};
129131
const provenance = util.createProvenance(firesDataOptions);

lib/kmz.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ const DOMParser = require('xmldom').DOMParser;
3030
const togeojson = require('@publicdocs/togeojson');
3131

3232

33-
exports.loadKmz = async function(url, path, toGeoJson, includeOtherFiles) {
33+
exports.loadKmz = async function(url, path, toGeoJson, includeOtherFiles, timeoutMs) {
3434
try {
3535
await promisify(fs.unlink)(path);
3636
} catch (err) {}
3737
const body = await rp({
3838
url: url,
3939
encoding: null,
40+
timeout: timeoutMs || 1200000,
4041
});
4142
const zip = await JSZip.loadAsync(body);
4243
await Promise.all(_.map(zip.files, (k) => {

lib/nfsa.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,15 @@ const processNfsaFire = function(e, proj) {
5151
return ret;
5252
};
5353

54-
exports.getFires = async function(userAgent, includeEmergingNew, includeEmergingOld) {
54+
exports.getFires = async function(userAgent, includeEmergingNew, includeEmergingOld, timeoutMs) {
5555
const dataOptions = {
5656
uri: 'https://maps.nwcg.gov/sa/publicData.json',
5757
qs: {
5858
},
5959
headers: {
6060
'User-Agent': 'Request-Promise; ' + userAgent,
6161
},
62+
timeout: timeoutMs || 120000,
6263
json: true,
6364
};
6465

0 commit comments

Comments
 (0)