Skip to content

_⚠️ Potential issue_ | _🔴 Critical_ #153

@JoshuaChi

Description

@JoshuaChi

⚠️ Potential issue | 🔴 Critical

Fix async usage of FileStateMachine::new.

FileStateMachine::new is synchronous (Result<Self>), but the snippet calls .await?. This won’t compile—await on a non-Future and ? on a value already moved into Arc::new. Drop the .await so the example reflects the actual API.

-    let state_machine = Arc::new(FileStateMachine::new(path.join("state_machine")).await?);
+    let state_machine = Arc::new(FileStateMachine::new(path.join("state_machine"))?);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    // Configure storage
    let path = PathBuf::from("/tmp/db");
    let storage_engine = Arc::new(FileStorageEngine::new(path.join("storage"))?);
    let state_machine = Arc::new(FileStateMachine::new(path.join("state_machine"))?);
🤖 Prompt for AI Agents
In README.md around lines 54 to 58, the example incorrectly uses `.await?` for
FileStateMachine::new (which returns Result<Self>, not a Future) and applies `?`
inside Arc::new; remove the `.await` and ensure the fallible call is resolved
before/while constructing the Arc (e.g., call
FileStateMachine::new(path.join("state_machine"))? and pass the resulting value
into Arc::new) so the code compiles and error propagation works as intended.

Originally posted by @coderabbitai[bot] in #149 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions