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

Fix improper handling of msg.results in chunk callbacks (#964) #1076

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jongwoo328
Copy link

Fix #964.

The delete msg.results; statement was likely introduced for memory optimization.
However, this caused the results to not be correctly passed as a parameter to complete when a chunk callback was present.

To address this, the release point of msg.results has been adjusted to ensure that results are properly passed to complete in cases where a chunk callback is used.

Copy link
Collaborator

@pokoli pokoli left a comment

Choose a reason for hiding this comment

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

Thanks for submiting the PR.

Do you think it should be easy to have a test suite which tests that the chunk Callback gets proper results? It will be great to include such test to prevent any regresion on the future.

var worker = workers[workerId];
if (isFunction(worker.userComplete))
worker.userComplete(results);
worker.terminate();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you elaborate why wee need to terminate the worker only when a function is defined?

Copy link
Author

Choose a reason for hiding this comment

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

I think I may have unintentionally changed the original flow while modifying the code. I'll revert back to. Thank you.

@jongwoo328
Copy link
Author

Sure.

Should I add test to the node_test.js and CUSTOM_TEST in test-cases.js?

@pokoli
Copy link
Collaborator

pokoli commented Nov 21, 2024

Should I add test to the node_test.js and CUSTOM_TEST in test-cases.js?
test-cases.js sounds like the right path for such test.

I will wait for your test before merging this.

@jongwoo328
Copy link
Author

I've addressed my mistakes and adding tests.
Please let me know if there's anything else that needs to be adjusted.
Thank you for your guidance!

@jongwoo328 jongwoo328 requested a review from pokoli November 22, 2024 08:01
@pokoli
Copy link
Collaborator

pokoli commented Nov 22, 2024

I've addressed my mistakes and adding tests. Please let me know if there's anything else that needs to be adjusted. Thank you for your guidance!

I've run the test and I see your new test is failing. Could you have a look and address it? TIA

@jongwoo328
Copy link
Author

Previous fixes didn't work on node environments 😅.
When using ChunkStreamer in a node environment, the _completeResults value being passed to complete was being set to undefined if the user provided the chunk option (in parseChunk).
I added code to store the results in _completeResults before setting results to undefined so that result can be properly passed to complete even if the chunk option is given.

Now it passes all tests!

@jongwoo328
Copy link
Author

Hi @pokoli
just checking in to see if there’s any feedback or updates on this PR. Let me know if I should adjust anything. Thanks!

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.

When using chunks callback, complete callback parameters are undefined
2 participants