Refactor HTTP connection requests
This commit is contained in:
1 parent
fa1e40e370
commit
bded263adf
3 files changed
+53
-15
No files matched your search
@@ -531,6 +531,11 @@ router.post("/devices/:id/tasks", async (ctx) => {
|
||||
}
|
||||
) as number;
|
||||
|
||||
const socketTimeout: number = ctx.socket["timeout"];
|
||||
|
||||
// Disable socket timeout while waiting for postTasks()
|
||||
if (socketTimeout) ctx.socket.setTimeout(0);
|
||||
|
||||
const res = await apiFunctions.postTasks(
|
||||
ctx.params.id,
|
||||
ctx.request.body,
|
||||
@@ -538,6 +543,9 @@ router.post("/devices/:id/tasks", async (ctx) => {
|
||||
device
|
||||
);
|
||||
|
||||
// Restore socket timeout
|
||||
if (socketTimeout) ctx.socket.setTimeout(socketTimeout);
|
||||
|
||||
log.tasks = res.tasks.map((t) => t._id).join(",");
|
||||
|
||||
logger.accessInfo(log);
|
||||
|
||||
Reference in new issue
Block a user