Skip to content

Commit

Permalink
Merge pull request #68 from tnc-ca-geo/set-timeout
Browse files Browse the repository at this point in the history
Set Timeout to 10s
  • Loading branch information
nathanielrindlaub authored Sep 18, 2023
2 parents ea37b1f + 95753ff commit a1cd475
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
31 changes: 31 additions & 0 deletions ingest-image/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions ingest-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
"mime-types": "^2.1.35",
"rimraf": "^5.0.0",
"sharp": "^0.32.0",
"strtime": "^1.1.2",
"uuid": "^9.0.0"
"strtime": "^1.1.2"
},
"devDependencies": {
"eslint": "^8.33.0",
Expand Down
8 changes: 7 additions & 1 deletion ingest-image/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ export default class Task {
} else {
await this.copy_to_prod(md);
}

} catch (err) {
// backstop for unforeseen errors returned by the API
// and errors resizing/copying the image to prod buckets.
Expand Down Expand Up @@ -368,15 +367,22 @@ export default class Task {

async function fetcher(url, body) {
console.log('Posting metadata to API', JSON.stringify(body));

const controller = new AbortController();
const id = setTimeout(() => controller.abort(), 10_000);

const res = await fetch(url, {
method: 'POST',
signal: controller.signal,
headers: {
'Content-Type': 'application/json',
'x-api-key': APIKEY
},
body: JSON.stringify(body)
});

clearTimeout(id);

if (!res.ok) {
const texterr = await res.text();
let jsonerr;
Expand Down

0 comments on commit a1cd475

Please sign in to comment.