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: worker kept open when it shouldn't #119

Merged
merged 2 commits into from
Mar 27, 2024

Conversation

maxime1992
Copy link
Contributor

This closes #116

@maxime1992 maxime1992 requested a review from zakhenry March 26, 2024 20:23
@maxime1992 maxime1992 self-assigned this Mar 26, 2024
@maxime1992
Copy link
Contributor Author

I've explained more about the fix here for reference #116 (comment)

Copy link

codecov bot commented Mar 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (2c9fe41) to head (8b68204).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #119   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines           71        70    -1     
  Branches        16        16           
=========================================
- Hits            71        70    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zakhenry zakhenry force-pushed the fix/worker-kept-open-when-it-should-not branch from f57d27c to 91001ad Compare March 26, 2024 22:03
@@ -69,7 +69,7 @@ export function fromWorkerPool<I, O>(
}),
map(
([worker, unitWork]): Observable<O> => {
return fromWorker<I, O>(() => worker.factory(), of(unitWork), selectTransferables, {
return fromWorker<I, O>(() => worker.factory(), concat(of(unitWork), NEVER), selectTransferables, {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

even though there's a test for it now, I think it's worth having a comment here explaining why the concat and never for the next time we read the code (prob in a long time and we won't remember why)

@christian-schlichtherle

Please excuse my insistence, but I think you still need to change the from-worker.ts file as shown in my PR. Reason is that the API contract of the interface Observer requires a call to either .error(error) or .complete() to signal the end of the stream. The current code is clearly breaking this contract.

@zakhenry
Copy link
Collaborator

zakhenry commented Mar 26, 2024

@christian-schlichtherle it's a little more complicated than that, because with the worker interface we're not dealing with regular observables of values, but with observables of notifications. For this reason we don't expect to call .error or .complete because these signals are present as notifications, and the dematerialize at the end will convert that to the expected observable flow.

I've tried out your fix and unfortunately it breaks the worker pool logic, so we can't accept that PR as-is. We're working on a fix but it might be a few days because this isn't our top priority right now.

@zakhenry zakhenry force-pushed the fix/worker-kept-open-when-it-should-not branch from 91001ad to 7a88a65 Compare March 26, 2024 23:15
…in the pool context to keep the workers alive
@zakhenry zakhenry force-pushed the fix/worker-kept-open-when-it-should-not branch from 7a88a65 to 8b68204 Compare March 26, 2024 23:18
@zakhenry
Copy link
Collaborator

@christian-schlichtherle this PR is now ready I believe and should solve your issue. I'll wait for @maxime1992 to review (he is France timezone) and then we should be good to go.

@maxime1992
Copy link
Contributor Author

Tested and LGTM

@maxime1992 maxime1992 merged commit 01e4017 into master Mar 27, 2024
3 checks passed
Copy link

🎉 This PR is included in version 6.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

responseObserver.complete() is not called
4 participants