Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Timeout to 10s #68

Merged
merged 3 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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