Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for AsyncIterator #132

Open
Modeeeeeee opened this issue Nov 13, 2024 · 10 comments
Open

Add support for AsyncIterator #132

Modeeeeeee opened this issue Nov 13, 2024 · 10 comments

Comments

@Modeeeeeee
Copy link

Currently, the harFromMessages function in the chrome-har module does not support asynchronous iteration using for await...of. This limitation makes it difficult to process asynchronous streams of messages efficiently.
I would like to request adding support for for await...of to the harFromMessages function so that it can accept an AsyncIterator. This would allow users to process asynchronous streams of messages more efficiently.
As an alternative, users can manually collect all messages into an array before passing them to harFromMessages. However, this approach is not efficient for large streams of messages and can lead to high memory usage.

Here is an example of how the updated harFromMessages function could look with support for AsyncIterator:

async function harFromMessages(messages, options) {
options = Object.assign({}, defaultOptions, options);

const ignoredRequests = new Set(),
rootFrameMappings = new Map();

let pages = [],
entries = [],
entriesWithoutPage = [],
responsesWithoutPage = [],
paramsWithoutPage = [],
responseReceivedExtraInfos = [],
currentPageId;

for await (const message of messages) {
// Process each message
console.log(message);
}

// Rest of the function logic
}

module.exports = { harFromMessages };

@soulgalore
Copy link
Member

Hi @Modeeeeeee do you have time to do a PR, I can help out with the testing?

@Modeeeeeee
Copy link
Author

@soulgalore I will take a look in the next couple of hours

@Modeeeeeee
Copy link
Author

@soulgalore #133. Added a dummy test but you can adjust it yourself to your liking

@Modeeeeeee
Copy link
Author

@soulgalore Any update on this ?

@soulgalore
Copy link
Member

Sorry I haven't had time. There's been an issue with Firefox 132 running in Docker in another project that takes my time until it's solved.

@Modeeeeeee
Copy link
Author

@soulgalore just a weekly check if there is no updates

@Modeeeeeee
Copy link
Author

@soulgalore Hi, do you have time to look into this ?

@Modeeeeeee
Copy link
Author

@soulgalore Any update ?

@soulgalore
Copy link
Member

Hi @Modeeeeeee sorry for the late answer. So harFromMessages will change to return to a promise, so this needs to go in a major release.

@Modeeeeeee
Copy link
Author

@soulgalore Okay, when you have the time look into the PR and schedule a release

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

No branches or pull requests

2 participants