Skip to content

Commit ccdb678

Browse files
committed
fix: save_account lock timeout
There was a setTimeout here that was supposed to be replaced with the timeout feature on LockService, but it looks like that never happened.
1 parent 1a07180 commit ccdb678

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/backend/src/routers/save_account.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const {
2626
const auth = require('../middleware/auth.js');
2727
const config = require('../config');
2828
const { DB_WRITE } = require('../services/database/consts');
29+
const { SECOND } = require('@heyputer/putility/src/libs/time.js');
2930

3031
// -----------------------------------------------------------------------//
3132
// POST /save_account
@@ -93,10 +94,7 @@ router.post('/save_account', auth, express.json(), async (req, res, next)=>{
9394
return svc_lock.lock([
9495
`save-account:username:${req.body.username}`,
9596
`save-account:email:${req.body.email}`
96-
], async () => {
97-
await new Promise((rslv) => {
98-
setTimeout(rslv, 5000);
99-
});
97+
], { timeout: 5 * SECOND }, async () => {
10098
// duplicate username check, do this only if user has supplied a new username
10199
if(req.body.username !== req.user.username && await username_exists(req.body.username))
102100
return res.status(400).send('This username already exists in our database. Please use another one.');

0 commit comments

Comments
 (0)