This PR fixes a race condition where the buffer is being flushed when we destroy the DBOS executor. I saw sometimes the testRuntime would throw errors like Error flushing workflow inputs buffer... after tests. This is not an issue for normal execution because we never call destroy but could be confusing to see destroy errors in tests or debug mode.
Make sure we don't have two concurrent flushWorkflowBuffers() running by using the isFlushingBuffers flag.
Make sure we wait for buffers to be exported before destroying systemDatabase.
This PR fixes a race condition where the buffer is being flushed when we destroy the DBOS executor. I saw sometimes the testRuntime would throw errors like
Error flushing workflow inputs buffer...
after tests. This is not an issue for normal execution because we never calldestroy
but could be confusing to see destroy errors in tests or debug mode.flushWorkflowBuffers()
running by using theisFlushingBuffers
flag.systemDatabase
.