Avoid race conditions from writing res status twi
This commit is contained in:
parent
ea22f3bab9
commit
37943b145c
1 changed files with 25 additions and 22 deletions
|
|
@ -2463,14 +2463,15 @@ module.exports = async (
|
|||
const epubForDecryption = req.header(EPUB_FOR_DECRYPT_HEADER)
|
||||
const { path } = req.params
|
||||
logger.info(`gun otheruser ONCE: ${path}`)
|
||||
const data = await handleGunFetch({
|
||||
path,
|
||||
startFromUserGraph: true,
|
||||
type: 'once',
|
||||
publicKeyForDecryption,
|
||||
epubForDecryption
|
||||
})
|
||||
res.status(200).json({
|
||||
data: await handleGunFetch({
|
||||
path,
|
||||
startFromUserGraph: true,
|
||||
type: 'once',
|
||||
publicKeyForDecryption,
|
||||
epubForDecryption
|
||||
})
|
||||
data
|
||||
})
|
||||
} catch (e) {
|
||||
logger.error(e)
|
||||
|
|
@ -2486,14 +2487,15 @@ module.exports = async (
|
|||
const epubForDecryption = req.header(EPUB_FOR_DECRYPT_HEADER)
|
||||
const { path } = req.params
|
||||
logger.info(`gun self user LOAD: ${path}`)
|
||||
const data = await handleGunFetch({
|
||||
path,
|
||||
startFromUserGraph: true,
|
||||
type: 'load',
|
||||
publicKeyForDecryption,
|
||||
epubForDecryption
|
||||
})
|
||||
res.status(200).json({
|
||||
data: await handleGunFetch({
|
||||
path,
|
||||
startFromUserGraph: true,
|
||||
type: 'load',
|
||||
publicKeyForDecryption,
|
||||
epubForDecryption
|
||||
})
|
||||
data
|
||||
})
|
||||
} catch (e) {
|
||||
logger.error(e)
|
||||
|
|
@ -2524,16 +2526,17 @@ module.exports = async (
|
|||
})
|
||||
return
|
||||
}
|
||||
const data = await handleGunFetch({
|
||||
path,
|
||||
startFromUserGraph: false,
|
||||
type,
|
||||
publicKey,
|
||||
publicKeyForDecryption,
|
||||
epubForDecryption
|
||||
})
|
||||
try {
|
||||
res.status(200).json({
|
||||
data: await handleGunFetch({
|
||||
path,
|
||||
startFromUserGraph: false,
|
||||
type,
|
||||
publicKey,
|
||||
publicKeyForDecryption,
|
||||
epubForDecryption
|
||||
})
|
||||
data
|
||||
})
|
||||
} catch (err) {
|
||||
res
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue