Historian does not always archive the value "on change"

I have two variables linked by a script. Once WriteRequest gets value of 1, script executes and changes the value of WriteDone to 1. Looks like the script is running, but history not always see the change in value of WriteRequest. What can we do to fix it?

What are the polling (tag group pace) and history settings of WriteRequest ? If you aren’t polling fast enough, you can miss events.