mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-20 09:01:19 +00:00
feat(backend): make FeedSourceProvider async (#77)
* feat(backend): make FeedSourceProvider async Make feedSourceForUser and FeedSourceProviderFn return promises. Use Promise.allSettled to tolerate partial provider failures. Guard concurrent getOrCreate calls with in-flight promise dedup. Return 503 from HTTP handlers when session creation fails. Co-authored-by: Ona <no-reply@ona.com> * fix(backend): handle remove() during in-flight session creation Cancel pending getOrCreate when remove() is called mid-flight. Destroy the resulting session to prevent it from leaking. Co-authored-by: Ona <no-reply@ona.com> --------- Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
@@ -44,7 +44,15 @@ async function handleUpdateLocation(c: Context<Env>) {
|
||||
|
||||
const user = c.get("user")!
|
||||
const sessionManager = c.get("sessionManager")
|
||||
const session = sessionManager.getOrCreate(user.id)
|
||||
|
||||
let session
|
||||
try {
|
||||
session = await sessionManager.getOrCreate(user.id)
|
||||
} catch (err) {
|
||||
console.error("[handleUpdateLocation] Failed to create session:", err)
|
||||
return c.json({ error: "Service unavailable" }, 503)
|
||||
}
|
||||
|
||||
await session.engine.executeAction("aelis.location", "update-location", {
|
||||
lat: result.lat,
|
||||
lng: result.lng,
|
||||
|
||||
Reference in New Issue
Block a user