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:
@@ -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(() =>
|
||||
|
||||
Reference in New Issue
Block a user