-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
24hr looppi vanhojen Sessioneiden poistoon | Antti/loop-for-deleting-expired-sessions #52
Conversation
… where a void return was expected. And await should not be needed at this point anyways
… it is done correctly without chances of 'fatal' error
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
pages/api/auth/login.ts
Outdated
// starts a interval that deletes expired sessions every 24 hours | ||
// this is not awaited because it should not be mandatory to wait this getting ready | ||
// old Sessions do not have a usage anyways | ||
deleteExpiredSessionsLoop().catch((e) => { | ||
console.error(e); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
En laittanut tätäkään await
iin, koska ei kait tässä kannata odotuttaa turhaan. Vanhoilla Sessioneilla ei kuitenkaan ole enää varsinaista käyttöä, koska luodaan aina kirjautuessa uusi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eikös tämä ole nyt tarpeeton, kun käytetään Vercelin cronia?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Joo, oli tämäkin jäänyt poistamatta 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tämä ei toimi Vercelissä sen serverless-toteutuksen takia. Tässä ChatGPT:n vastaus, joka selittää asian hyvin.
Maksimiaika setTimeout
lle hobby-planillä on 60 sekuntia.
Täältä löytyy ohjeet, miten tehdään Vercelin cron job.
Tein alunperin noilla Vercelin cron jobseilla, mutta tajusin etten pysty testaamaan toimiiko se (ei ilmeisesti toimi omalla koneella) 😄 ChatGPT:n vastaus oli hyvä 👍 |
Tämä kommentti on vanhentunutTarvitseeko / kannattaako Lähinnä siksi, että jos sitä ei ole suojattu, periatteessa kuka tahansa voisi ajaa vanhojen Sessioneiden tyhjentäjäskriptin. Normikäyttäjä ei endpointtia löydä, mutta boteilla on mahdollisuus. Jos endpointtia ei suojata, olisiko hyvä lisätä jokin "cooldown", että kuinka usein skriptin voi ajaa? Tuolla estettäisiin "turha spämmi". Vai meneekö tämmöinen hifistelyksi? 😅 Edit: löyty Cron Jobien suojaukseen linkki: https://vercel.com/docs/cron-jobs/manage-cron-jobs#securing-cron-jobs |
Nyt pitäisi olla lähempänä oikeaa. En pystynyt cron jobia testaamaan, mutta API:n pystyin. API itsessään toimi Eli enää täytyy tietää onko yhteensopiva Vercelin kanssa ja toimiiko cron job 😄 |
pages/api/auth/login.ts
Outdated
// starts a interval that deletes expired sessions every 24 hours | ||
// this is not awaited because it should not be mandatory to wait this getting ready | ||
// old Sessions do not have a usage anyways | ||
deleteExpiredSessionsLoop().catch((e) => { | ||
console.error(e); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eikös tämä ole nyt tarpeeton, kun käytetään Vercelin cronia?
|
||
// if authHeader was correct we can delete expired sessions | ||
|
||
await lucia.deleteExpiredSessions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lisäisin tähän console.log
in, niin näkisi backendin lokeista helposti että cron toimii oikein.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lisäisin tähän console.login, niin näkisi backendin lokeista helposti että cron toimii oikein.
Tämä taisi jäädä lisäämättä?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Joo tämä jäi, sori! Lisään heti! 👍
Poistin deleteExpiredSessionsLoop:it (olin jossain branchissa nuo jo poistanut, koska näkyi terminaalin historiassa. En tiedä vain missä 🤣) Mergesin |
|
||
// if authHeader was correct we can delete expired sessions | ||
|
||
await lucia.deleteExpiredSessions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lisäisin tähän console.login, niin näkisi backendin lokeista helposti että cron toimii oikein.
Tämä taisi jäädä lisäämättä?
Tässä prototyyppi loopista 😄