Various refactoring for dynamic worker loading#4360
Merged
Conversation
All of `WorkerSource` except its last few lines are a pure cut-and-paste from Worker::Script. This is needed so that we can use `WorkerSource` in io-channels.h to define a dynamic isolate channel. io-channels.h cannot include worker.h as this would be a cyclic dependency.
The current version assumes flags always originate in capnp, but dynamic isolates will want to specify them, well, dynamically.
Similar to #4082, we want the representation of the worker definition passed to `makeWorker()` to not have to come from a workerd config file. This introduces an intermediate representation, `WorkerDef`, to represent this. No logic has changed here, code has just moved around.
anonrig
reviewed
Jun 18, 2025
This will be needed as the dynamic isolate API can pass other kinds of Frakenvalues.
Much of ErrorReporter will be shared with dynamic isolates, but the way errors themselves are reported needs to be different. This introduces a new type `ConfigErrorReporter` for the specific purpose of top-level workerd config errors.
The link callback for WorkerServices was reporting errors directly using `reportConfigError()` but this will not be appropriate for dynamically-loaded services.
e26c3d1 to
91964a4
Compare
anonrig
approved these changes
Jun 18, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is just some simple refactoring needed for my upcoming dynamic worker loading feature. Figured I'd put these up and get them merged before conflicts arise (especially the first commit, which moves a bunch of code).