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: terminate the process correctly #2499

Closed
wants to merge 10 commits into from

Conversation

tsctx
Copy link
Member

@tsctx tsctx commented Dec 5, 2023

Fixes #2413

@tsctx
Copy link
Member Author

tsctx commented Dec 5, 2023

Sorry, but I could not create a unit test.

@ronag ronag requested a review from KhafraDev December 5, 2023 09:04
@codecov-commenter
Copy link

codecov-commenter commented Dec 5, 2023

Codecov Report

Attention: 159 lines in your changes are missing coverage. Please review.

Comparison is base (e39a632) 85.54% compared to head (b126e91) 84.31%.
Report is 151 commits behind head on main.

Files Patch % Lines
lib/fetch/index.js 66.01% 52 Missing ⚠️
lib/fetch/util.js 31.42% 48 Missing ⚠️
lib/handler/RetryHandler.js 74.35% 30 Missing ⚠️
lib/fetch/headers.js 90.00% 6 Missing ⚠️
lib/api/readable.js 88.88% 5 Missing ⚠️
lib/compat/dispatcher-weakref.js 28.57% 5 Missing ⚠️
lib/client.js 93.75% 3 Missing ⚠️
lib/core/tree.js 94.23% 3 Missing ⚠️
lib/core/util.js 95.55% 2 Missing ⚠️
lib/fetch/request.js 90.47% 2 Missing ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2499      +/-   ##
==========================================
- Coverage   85.54%   84.31%   -1.24%     
==========================================
  Files          76       79       +3     
  Lines        6858     7211     +353     
==========================================
+ Hits         5867     6080     +213     
- Misses        991     1131     +140     

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

lib/fetch/body.js Outdated Show resolved Hide resolved
Copy link
Member

@KhafraDev KhafraDev left a comment

Choose a reason for hiding this comment

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

A test that just makes a fetch call in a worker sounds useful. FWIW I couldn't repro it locally either, but maybe it is in the CIs.

Is there a reason you're using the first tee'd stream instead of the second? IIRC I had issues using the first one.

@tsctx
Copy link
Member Author

tsctx commented Dec 5, 2023

A test that just makes a fetch call in a worker sounds useful. FWIW I couldn't repro it locally either, but maybe it is in the CIs.

Is there a reason you're using the first tee'd stream instead of the second? IIRC I had issues using the first one.

No particular reason. What problems did you have?

@KhafraDev
Copy link
Member

Don't recall exactly, probably related to the comment

@tsctx
Copy link
Member Author

tsctx commented Dec 5, 2023

Is this? #1700

@KhafraDev
Copy link
Member

that's why we needed the tee, not why I used the second stream. Just wondering, how do you know that this fixes the issue?

@tsctx
Copy link
Member Author

tsctx commented Dec 5, 2023

I found that I could run a reproducible script of 2 issues and fix it.

@KhafraDev
Copy link
Member

why can't that be made into a test?

@tsctx
Copy link
Member Author

tsctx commented Dec 5, 2023

why can't that be made into a test?

This is because it requires access to an external server.
That test did not work when I set up a local server.

If you want the test, you need a few days. Still, you may not be able to create the test.

@KhafraDev
Copy link
Member

as I mentioned before, it might not work locally but it might run on the CI, which is better than nothing (even if it doesn't work on the CI either)

@tsctx
Copy link
Member Author

tsctx commented Dec 5, 2023

as I mentioned before, it might not work locally but it might run on the CI, which is better than nothing (even if it doesn't work on the CI either)

I can't do that right now. I will do some research

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina
Copy link
Member

mcollina commented Dec 7, 2023

that'd be a good test

@AriPerkkio
Copy link

AriPerkkio commented Dec 7, 2023

@tsctx does this fix reproduction case from #2026 for you locally? I can still reproduce it after applying the changes from this PR.

Running stress command in second terminal makes reproducing the issue a lot easier.

@tsctx
Copy link
Member Author

tsctx commented Dec 7, 2023

Hi @AriPerkkio,
Changes are added. Is this fixed?

@ronag
Copy link
Member

ronag commented Dec 8, 2023

@KhafraDev I'd like you approval on this before merging.

@AriPerkkio
Copy link

Hi @AriPerkkio,
Changes are added. Is this fixed?

No, #2026 still gets stuck with these changes applied locally:

ari ~/Git/undici (main) $ node repro.mjs 
Unable to terminate
...
There are 1 stuck workers
Forcing process.exit on main thread

@tsctx
Copy link
Member Author

tsctx commented Dec 8, 2023

Hi @AriPerkkio,

Changes are added. Is this fixed?

No, #2026 still gets stuck with these changes applied locally:

ari ~/Git/undici (main) $ node repro.mjs 

Unable to terminate

...

There are 1 stuck workers

Forcing process.exit on main thread

Thanks for the report! I thought I had fixed it.

@KhafraDev
Copy link
Member

@tsctx it's most likely a bug in node, not really sure how much of it can be fixed here. If you find a fix for nodejs/node#44985 it would probably help.

@tsctx tsctx closed this Dec 25, 2023
@tsctx tsctx deleted the fix/terminate-the-process-correctly branch December 25, 2023 08:29
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.

Tests not terminating after execution with msw when using FormData and Blob
7 participants