-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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: call worker unref
instead of terminate
#10120
Conversation
🦋 Changeset detectedLatest commit: 574c4cd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Hmm. The point of doing it in a worker/subprocess was to kill any straggling processes: https://github.com/sveltejs/kit/pull/10120/files#diff-348357ad608e5d50118974da4744182066b02236abef646543dbd7b40b6b8b27R5 From your description, I'm not sure it sounds like that will still happen? |
Can you point out where in the description that made you unsure so that I can help out clarify them? We do have this code in the test that make sure that everything is shut down correctly, and it does fail if we only remove |
Mhm, this is kind of a weird situation, as it seems we don't have equivalent measures to stop the process. From my limited understanding So yeah, maybe |
@ignatiusmb sorry for the two month hiatus in responding. The part I was referring to was "this would allow the long running process that seems to happen after terminate is called to finish without being interrupted". The problem I believe we were initially trying to solve was to kill an infinitely running process. If we're not interrupting then I wonder if we're really having the desired effect |
We have a test that ensures child processes don't keep the parent process alive after prerendering is complete: kit/packages/kit/test/prerendering/basics/src/hooks.server.js Lines 20 to 23 in 108a6a8
As such, this PR seems good to merge to me (though I confess I don't quite understand what difference it would make in practice) |
According to the docs,
terminate
seems to effectively stop all execution in the thread, as soon as possible. This seems to break some long running process — which was working withchild_process
before — when prerendering, either because the ample amounts of prerendered pages/routes, the huge amount of data that needs to be (pre)processed for each routes, or a combination of both.Substituting
terminate
withunref
would allow the worker to exit when it finds that it's the only active one in the event system, this would allow the long running process that seems to happen afterterminate
is called to finish without being interrupted.The error thrown by the
terminate
method also seems to be very vague and random, trying toawait
it seems to give a more helpful message along with a stacktrace, but still not enough to figure out what's going on and why it's prematurely exiting the thread. This is mostly an excuse because I couldn't seem to find a way to recreate the issue in a smaller scale and push in a failing test.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.