Repository navigation
feat: prerender & analyse in worker rather than subprocess to support Deno - #9919
Conversation
🦋 Changeset detectedLatest commit: 333e7ed 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 |
Rich-Harris
left a comment
There was a problem hiding this comment.
this LGTM! thank you. just had one small observation, inline.
I'm not sure I totally understand how this affects Deno though — it looks like child_process and worker_threads are both implemented. Is there some nuance I'm missing?
It sounds to me like Deno implements |
Co-authored-by: Rich Harris <[email protected]>
|
Thanks for the ping @benmccann.
That's true, we currently don't have support for the |
|
Thanks! Yeah, we can wait to merge this on our side then. I'm also fine going either the |
|
Workers would definitely be easier - we just need to update once-working code. I'll prioritize this work over the next week and get back to you once it's released (I'll target to release in Deno v1.33.4 next week). |
|
iirc we have been using child_process to ensure resources are properly cleaned up (eg db connections). Is that still the case with worker? |
@dominikg I believe so - workers use separate OS threads, so once the worked is closed/terminated the resources will be released back to the OS. |
|
This code guarantees that everything is correctly shut down — if it wasn't, the tests would never complete: kit/packages/kit/test/prerendering/basics/src/hooks.server.js Lines 20 to 23 in 9f5642d So given that the tests are passing I'm confident that it works correctly. |
|
Please take a look at #9989 - seems that using workers require also env cleanup. |
Fixes "#17617" Build workers unconditionally replaced the inherited FORCE_COLOR with '1'. Consequently, setting NO_COLOR caused Node to warn about conflicting settings during otherwise successful builds, and explicit color-disable/depth settings were lost. The forced-color default was introduced with improved diagnostics in #16374. It still serves a purpose: worker output does not otherwise retain terminal color detection. Removing it entirely would regress those diagnostics. Instead, only add the FORCE_COLOR default when the parent hasn't disabled colors with a non-empty NO_COLOR, and pass everything the parent sets through unchanged. An explicit FORCE_COLOR (including 0) is preserved, and when the parent sets both variables the worker gets both, so it resolves colors the same way the parent does. An empty NO_COLOR counts as unset, matching Node and the NO_COLOR spec. This central change covers route analysis, prerendering, and fallback generation. It preserves environment inheritance from #8777, worker_threads compatibility from #9919, and the cleanup/exit-handler behavior from #17135. Regression coverage uses the existing real-worker fixture rather than mocking worker construction. - [Ported SvelteLab reproduction](https://www.sveltelab.dev/#code=N4IgDghgxg1hDmBTAdAKwM4HsB2IBcoAZgJYA2i%2BoUOALotjeviMADras2sjYQC2ibngAE3GMRoBabJknVSmAE6SA7hEXZi2eNwA07TtzCLiANwh0hwmooCuifRy4hTiRemI4r3AAzI-AIx6Bs40AJ5ggviiIHyYACa25MFO3OhQJmCMVmypzvGIpt4uEojCBUUgjobOAEa2ZPHFpqXC9Y0pNUaKhcSIKs2txr39nVzOw5A9xeiupHSS4jTC6GHYUMIAPpvCiFAAFpjCAOTHY4Yg7aTxeDJymAqKxQByAPIA%2BgDCrwAyrwBKAF4AsIWnQ2g1rtwQgBfar5QoAEUQkWwBXWfXQORCFwAArNEPNEBgAPQQeIQLJuSQQWw0TDFAAc-n852c%2BLmdFJS2KAGZkAEBWzuBzCVz0CSwYhJGBSLZ4FpJASicUAOzIflBKo45zKyzRbgAVmQhvVvOFIHCkXSmWcIm4ADYWebtXluFKmRqTdCnDD2H7cDC4eBsGA%2BKolDB0JAoCgwvxSJQQCRyEnqAx6IxmPQFdhEABlGzEKA0EQ2ezsCCkBQqABCkPi6Dw7GEu3QVxu1jsgkDwfQiigSfixB6JaUYSTlLAyH2ND4iYIybIFEX6boDCYeBAAB4AITxTAliJlWfzgB87G3p9IwlIEG0gO49G4F6cV8Q5NfNW3AhoEGEBzqOgiA0I%2BIB0oQkiMtwwgkl%2B4w-iB-68AIYEtP0YBKM4AG0JmYEqMQ8Q0PsgIVMW0oEUR%2By6MIWgSMQVZKlAVaIMCMFwTqiF-sIKGsdwdAAB5SOkLEwWueFpMxyQgLB8GcAApHqiBLDOH7xPJITbiS%2BxqfB261AkYTlBYEBKpyykSDKPQKOSkgUn%2BYGHK4TwgHJNDbsOpgrOE5BgcO0Z3mEIjiRuL6KeZKkGfEYTyVpnl6SSUVhK%2BWnXq%2BIBBroICKJgdKIJuoDDqO9KKBOi4ANSQEgyBKUmKYrlQuEbswV4BGeADqhLUAI1hHPm5kANISKlbWXmAZ4AGrEB4yzbv%2B%2Bw9IQjk0DQYBNiSJJKcgFQkgeUASjyrlbTte0HcNZJnr1wg9OS1g6eUh62AIDAWJ42BaeN7AZUGP1ZYw6YkPAaBYLgi71WmTVZluuQXIgQn0I2xQACRTiS-04ID5wgN1YDLoorxZG9WLRDD4xpEWJZWOWPacHCOIgFoUBygUVgANppAOegxFKyAA8QQPZCAAC6-pfZlJR0LzGP88gUNEMuEMZs1W7EHwmGKMs5KUnQijCIQOV8CcopEqSWtUsotL0scADc7Cq%2BryzACsEUSMIMJ6wbRtKdyEiSqUNt22rWHCE7BQkHmnzS-Abse5ghvHFKAccHmAkO%2BUiCELS8zp%2BHiCR9ggMABSk7K8paE2wis0pSzF8IZs6I9duIXACUbstyL2Awi3tu9jCQA). Run build:no-color to reproduce the build warning with the pinned release. <!-- svelte-triage-bot:feedback-baseline:34a9e93738cd15903cc13bc4509c9647dd9d9238 --> --------- Co-authored-by: svelte-triage-bot <[email protected]> Co-authored-by: Tee Ming <[email protected]>
use
workersinstead ofchild_processrelated:
denoland/deno#17248
@benmccann would you be able to review this PR?