Skip to content

Unresolved Promise Causes Data Corruption on Auto-Save #73

Description

@vibhutomer

Description

In Govt-Billing-React/src/components/NewFile/NewFile.tsx, the newFile function automatically saves the user's current working file before initializing a blank workspace. However, it calls props.store._getFile() synchronously without the await keyword.

Impact

Because local storage operations return a Promise, the data variable holds a pending Promise object instead of the actual file data. When the code attempts to extract (data as any).created, it evaluates to undefined.
This results in the file being re-saved with a corrupted or missing creation timestamp, breaking chronological sorting and potentially causing errors in other parts of the app that expect valid date strings.

Proposed Solution

Convert the newFile arrow function into an async function and apply the await keyword to the props.store._getFile() call so the metadata resolves correctly before the new File object is constructed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions