mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
We had this error in our neo4j pod recently: ``` 2019-12-02 08:29:42.680+0000 ERROR Unable to schedule bolt session 'bolt-1018230' for execution since there are no available threads to serve it at the moment. You can retry at a later time or consider increasing max thread pool size for bolt connector(s). 2019-12-02 08:29:42.680+0000 ERROR Unable to schedule bolt session 'bolt-1018224' for execution since there are no available threads to serve it at the moment. You can retry at a later time or consider increasing max thread pool size for bolt connector(s). 2019-12-02 08:29:42.681+0000 ERROR Unable to schedule bolt session 'bolt-1018352' for execution since there are no available threads to serve it at the moment. You can retry at a later time or consider increasing max thread pool size for bolt connector(s). 2019-12-02 08:29:42.682+0000 ERROR Unable to schedule bolt session 'bolt-1018243' for execution since there are no available threads to serve it at the moment. You can retry at a later time or consider increasing max thread pool size for bolt connector(s). ``` Apparently the default is 400 threads. So we must have a leak somewhere.
38 lines
914 B
JavaScript
38 lines
914 B
JavaScript
import jwt from 'jsonwebtoken'
|
|
import CONFIG from './../config'
|
|
|
|
export default async (driver, authorizationHeader) => {
|
|
if (!authorizationHeader) return null
|
|
const token = authorizationHeader.replace('Bearer ', '')
|
|
let id = null
|
|
try {
|
|
const decoded = await jwt.verify(token, CONFIG.JWT_SECRET)
|
|
id = decoded.sub
|
|
} catch (err) {
|
|
return null
|
|
}
|
|
const query = `
|
|
MATCH (user:User {id: $id, deleted: false, disabled: false })
|
|
SET user.lastActiveAt = toString(datetime())
|
|
RETURN user {.id, .slug, .name, .avatar, .email, .role, .disabled, .actorId}
|
|
LIMIT 1
|
|
`
|
|
const session = driver.session()
|
|
let result
|
|
|
|
try {
|
|
result = await session.run(query, { id })
|
|
} finally {
|
|
session.close()
|
|
}
|
|
|
|
const [currentUser] = await result.records.map(record => {
|
|
return record.get('user')
|
|
})
|
|
if (!currentUser) return null
|
|
return {
|
|
token,
|
|
...currentUser,
|
|
}
|
|
}
|