Avoid to send HTTP result if already sent
MODIFY
src/server/rest/v1/service/TagService.ts
src/server/rest/v1/service/TagService.ts
@@ -543,7 +543,9 @@ export default class TagService {
method: 'handleImportTags',
});
// Respond
+ if (!res.headersSent) {
res.json({ ...result, ...Constants.REST_RESPONSE_SUCCESS });
+ }
next();
resolve();
});
@@ -603,10 +605,9 @@ export default class TagService {
}
});
});
- } catch (error) {
+ } finally {
// Release the lock
await LockingManager.release(importTagsLock);
- throw error;
}
}

MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -544,7 +544,9 @@ export default class UserService {
method: 'handleImportUsers',
});
// Respond
+ if (!res.headersSent) {
res.json({ ...result, ...Constants.REST_RESPONSE_SUCCESS });
+ }
next();
resolve();
});
@@ -606,10 +608,9 @@ export default class UserService {
}
});
});
- } catch (error) {
+ } finally {
// Release the lock
await LockingManager.release(importUsersLock);
- throw error;
}
}

Avoid to send HTTP result if already sent