Skip to content

Refactor cms-loader to use async/await for clarity#922

Open
raisakshii wants to merge 2 commits into
HSF:mainfrom
raisakshii:ref-cms-loader
Open

Refactor cms-loader to use async/await for clarity#922
raisakshii wants to merge 2 commits into
HSF:mainfrom
raisakshii:ref-cms-loader

Conversation

@raisakshii

@raisakshii raisakshii commented Jun 4, 2026

Copy link
Copy Markdown

Description

Refactors the readIgArchive method in CMSLoader to use modern asynchronous patterns (async/await and Promise.all). This resolves a potential race condition during file parsing and significantly improves code readability.

Key Changes

  • Fixed Race Condition: Replaced the fragile manual counter (let i = 1) with Promise.all to guarantee all files are completely unzipped and parsed before triggering the onFileRead callback.
  • Modernized Syntax: Migrated from nested .then() chains to a flat async/await control flow, eliminating callback hell.
  • Safer Error Handling: Added a try/catch block around the archive parsing logic to ensure the loadingManager resolves gracefully even if the .ig file is corrupt.
  • Optimized string replacements using a single-pass regex and added a finally block for reliable loading manager resolution.

@raisakshii

raisakshii commented Jun 4, 2026

Copy link
Copy Markdown
Author

could you please review this PR when you get a chance?

@lavjeetrai lavjeetrai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIU the approach is good ,but fix that failing error first

@raisakshii raisakshii marked this pull request as draft June 4, 2026 15:01
@raisakshii

Copy link
Copy Markdown
Author

thanks for review.i have converted it into draft .i'll reopen it when i 'll fix the errors

@raisakshii raisakshii marked this pull request as ready for review June 5, 2026 19:11
@raisakshii

Copy link
Copy Markdown
Author

@EdwardMoyse , could you please review this PR when you have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants