Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/replaceable-event-error-message-empty.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"nostream": patch
---

fix: include the actual error message in replaceable event rejection responses

`ReplaceableEventStrategy.execute()` sent clients a bare `error: ` command result
(with no message body) whenever `eventRepository.upsert()` failed for a reason other
than a duplicate event id. The underlying `error.message` was caught but never
included in the response, leaving clients with no actionable information about why
the event was rejected. The command result now includes `error.message`.
5 changes: 4 additions & 1 deletion src/handlers/event-strategies/replaceable-event-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export class ReplaceableEventStrategy implements IEventStrategy<Event, Promise<v
return
}

this.webSocket.emit(WebSocketAdapterEvent.Message, createEventCommandResult(event.id, false, 'error: '))
this.webSocket.emit(
WebSocketAdapterEvent.Message,
createEventCommandResult(event.id, false, `error: ${error.message}`),
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('ReplaceableEventStrategy', () => {
})

it('rejects if unable to upsert event', async () => {
const error = new Error()
const error = new Error('connection lost')
eventRepositoryUpsertStub.rejects(error)

await strategy.execute(event)
Expand All @@ -98,7 +98,7 @@ describe('ReplaceableEventStrategy', () => {
'OK',
'id',
false,
'error: ',
'error: connection lost',
])
})
})
Expand Down
Loading