Skip to content

Commit

Permalink
chore: handle error in websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldziher committed Dec 7, 2023
1 parent 6fd67ff commit 6ba44c6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-frontend-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 21
node-version: 16
- name: Install Firebase CLI
run: npm install -g firebase-tools
- name: Install PNPM
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 21
node-version: 16
- name: Install Firebase CLI
run: npm install -g firebase-tools
- name: Install PNPM
Expand Down
17 changes: 9 additions & 8 deletions .idea/externalDependencies.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions services/dashboard-backend/internal/api/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,25 @@ func CreatePayloadFromMessage(
FinishReason: msg.FinishReason,
}

isErr := *msg.FinishReason == "error"

if isErr {
log.Warn().Msg("stream ended due to an error. Check the api-gateway logs for more details")
}

if msg.PromptRequestRecordId != nil {
requestRecordID := exc.MustResult(db.StringToUUID(*msg.PromptRequestRecordId))
promptTestRecord := exc.MustResult(db.GetQueries().
promptTestRecord, createErr := db.GetQueries().
CreatePromptTestRecord(ctx, models.CreatePromptTestRecordParams{
PromptRequestRecordID: *requestRecordID,
Response: builder.String(),
VariableValues: serialization.SerializeJSON(data.TemplateVariables),
}))

payload.PromptTestRecordID = ptr.To(db.UUIDToString(&promptTestRecord.ID))
})
if createErr == nil {
payload.PromptTestRecordID = ptr.To(db.UUIDToString(&promptTestRecord.ID))
} else if !isErr {
log.Error().Err(createErr).Msg("failed to create prompt test record")
}
}

return serialization.SerializeJSON(payload)
Expand Down

0 comments on commit 6ba44c6

Please sign in to comment.