Commit upload session row before responding; client's follow-up GET raced the post-response commit into a 404
This commit is contained in:
parent
b541cc2314
commit
15381b2c41
1 changed files with 6 additions and 0 deletions
|
|
@ -86,7 +86,13 @@ async def create_upload(body: UploadSessionCreate, user: CurrentUser, session: S
|
|||
session, user.id, body.declared_mime_type, body.declared_size_bytes,
|
||||
body.title, body.client_recording_id, body.transcription_model,
|
||||
)
|
||||
# Commit BEFORE responding: FastAPI's get_session commits after the
|
||||
# response is sent, and the desktop client GETs /uploads/{id} the
|
||||
# instant it sees the 201 — an uncommitted row raced that follow-up
|
||||
# into a 404 "Upload status failed" (seen live Sep 18).
|
||||
await session.commit()
|
||||
except up.UploadError as e:
|
||||
await session.rollback()
|
||||
raise HTTPException(e.status_code, e.message) from None
|
||||
return us
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue