chore(workflows-sdk, utils): Prevent unnecessary serialization (#13413)

* chore(workflows-sdk, utils): Prevent unnecessary serialization

* Create poor-mugs-cheat.md
This commit is contained in:
Adrien de Peretti
2025-09-04 16:19:35 +02:00
committed by GitHub
parent bd571aca82
commit 55a35e4721
5 changed files with 31 additions and 11 deletions
@@ -82,16 +82,13 @@ export default class LocalEventBusService extends AbstractEventBusModuleService
// This is useful in the event of a distributed transaction where you'd want to emit
// events only once the transaction ends.
private async groupOrEmitEvent<T = unknown>(eventData: Message<T>) {
const eventData_ = JSON.parse(JSON.stringify(eventData))
const { options, ...eventBody } = eventData_
const { options, ...eventBody } = eventData
const eventGroupId = eventBody.metadata?.eventGroupId
if (eventGroupId) {
await this.groupEvent(eventGroupId, eventData_)
await this.groupEvent(eventGroupId, eventData)
} else {
const { options, ...eventBody } = eventData_
const options_ = options as { delay: number }
const options_ = eventData.options as { delay: number }
const delay = (ms?: number) => (ms ? setTimeout(ms) : Promise.resolve())
delay(options_?.delay).then(() =>