-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: clone history events to prevent mutation #479
base: main
Are you sure you want to change the base?
Conversation
e = await mutateEntity.get({ | ||
pk: "pk", | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: delete to clean up
// TODO: more efficient deep clone | ||
return item === undefined ? item : JSON.parse(JSON.stringify(item)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create issue?
const historyEvents = executor.history.slice(0); | ||
const historyEvents = executor.historyCloned.slice(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just use the cloned one in the executor's iterator and return the original array in .history
?
// clone the history so it cannot be modified by the user | ||
public historyCloned: HistoryStateEvent[]; | ||
|
||
constructor( | ||
private workflow: Workflow<any, Input, Output>, | ||
public history: HistoryStateEvent[], | ||
// TODO: properties used in the workflow should be encoded in the history to keep them constant between runs | ||
private propertyRetriever: PropertyRetriever, | ||
private eventualFactory: EventualFactory = createDefaultEventualFactory() | ||
) { | ||
this.historyCloned = deepClone(history); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use .historyCloned
in the iterator in here, leave it private, and then leave the original array in the .history
?
No description provided.