Repository navigation
fix(chat,mux): atomic message insert, fix mislabeled health field, real recording toggle - #1663
Merged
Merged
Conversation
…al recording toggle Atomic chat insert (StreamFi-x#764): replaces the separate INSERT + UPDATE stream_sessions pair in the chat POST handler with a single writable CTE. Both operations now run in one implicit transaction so a crash between them can never leave total_messages permanently out of sync with the actual row count. Stream health field (StreamFi-x#759): renames getMuxStreamHealth's lastSeen field to recentAssetId and adds a createdAt field. recent_asset_ids[0] is a Mux asset UUID string, not a timestamp — calling new Date() on it produces Invalid Date. The rename makes the type of the value explicit; createdAt supplies a genuine time reference for recency display. Recording toggle (StreamFi-x#755): replaces the documented no-op updateMuxStreamRecording with a real mux.video.liveStreams.update() call that sets new_asset_settings to enable or clear the recording policy. Adds structured logging consistent with the other helpers in this file. A comment notes that Mux applies the change to the next broadcast segment, not the one already in progress. Closes StreamFi-x#755 Closes StreamFi-x#759 Closes StreamFi-x#764 Closes StreamFi-x#765
|
@aniokedianne Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
@aniokedianne is attempting to deploy a commit to the david's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #755
Closes #759
Closes #764
Closes #765
Atomic chat message insert + counter update (#764)
app/api/streams/chat/route.ts— the POST handler ran a bareINSERT INTO chat_messagesfollowed by a separateUPDATE stream_sessions SET total_messages = total_messages + 1. A crash or connection drop between them lefttotal_messagespermanently one short with no recovery path. Replaced both statements with a single writable CTE (WITH new_msg AS (INSERT ...) _counter AS (UPDATE ...)), which runs inside one implicit Postgres transaction.Stream health field mislabeled as a timestamp (#759)
lib/mux/server.ts—getMuxStreamHealthreturnedlastSeen: liveStream.recent_asset_ids?.[0], butrecent_asset_idscontains Mux asset UUID strings, not timestamps.new Date(uuid)produces Invalid Date. Renamed the field torecentAssetIdso callers cannot mistake it for a Date, and addedcreatedAt: liveStream.created_atas a genuine time-based field for recency display.Recording toggle was a silent no-op (#755)
lib/mux/server.ts—updateMuxStreamRecordingreturned{ success: true }without contacting Mux, meaning the creator-facing "Enable Recording" toggle had no effect on the actual stream. Replaced with a realmux.video.liveStreams.update()call that setsnew_asset_settingsto a public-playback policy when enabling, or clears it when disabling. Added structured logging matching the other helpers in the file. The function now throws on Mux errors (the caller inupdates/[wallet]/route.tsalready swallows these and logs without failing the settings save). A comment notes that Mux applies recording changes to the next broadcast segment, not one already in progress.Tags table comma (#765)
The reported missing comma between
visibilityandcreated_atin thetagstable definition is not present in the currentdevbranch —schema.sqlline 185 already readsvisibility BOOLEAN DEFAULT true,with the comma. No change needed; includingCloses #765to track that the issue has been verified against current code.