-
Notifications
You must be signed in to change notification settings - Fork 260
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
A boot() method to explicitly initialize the PHP worker #1669
Conversation
This is ready for review now. Also, I wonder if bringing in files from git repositories could be expressed as a "read-only mount" 🤔 This would neatly interop with the CLI version. |
I know it's a large one and might be difficult to review. There's a few things I could extract, but unfortunately most of it is an atomic change. If nothing stands out, we could try deploying that on Monday with full readiness to rollback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not done reviewing but wanted to share progress so far because there is a blocker.
The Good:
- The name improvements in this PR help me so much. I started leaving comments about that, but there were so many that I eventually stopped commenting on it.
- Switching to explicit boot calls seems like a big improvement to clarity and function.
The Bad:
- This PR does not yet work in Safari. Trying to post a message containing FileSystemDirectoryHandle references is leading to a DataCloneError.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a big PR 😅
+1 to what @brandonpayton mentioned. I like how the code is now easier to follow and better named.
This feels like a good, timing for a refactor, we added a lot of features to the boot flow recently and some changes were all over the place.
There are some merge conflicts with trunk, so I'll look at those next. |
8f03503
to
e4f031d
Compare
I missed some thing in the original switch from passing OPFS handles to passing OPFS paths, and those should be fixed now. |
I am currently seeing a bug with creating a new site on device storage:
Discovered while testing for this review comment: Looking into it. |
It looks like I was mistaken about the "fix" for this PR because we aren't just passing around opfs paths. FileSystemDirectoryHandles are also used for local FS access, so we cannot just pass paths around and assume they are for OPFS. Since FileSystemDirectoryHandle instances cannot be transferred via Continuing to look into this. |
One thing to remember is that Safari doesn't support direct local FS access via |
I worked on adjusting this to use the following types: export type MountDevice =
| {
type: 'opfs';
path: string;
}
| {
type: 'local-fs';
// Since we have to prompt the user to get the FS handle,
// we cannot simply save a path and recreate the handle
// like we can do for OPFS. So we have to pass the handle between threads.
handle: FileSystemDirectoryHandle;
};
export interface MountDescriptor {
mountpoint: string;
device: MountDevice;
} Safari doesn't support structuredClone() for FileSystemHandle or the platform features we use to interact with the local device filesystem. Since we don't support local-fs sites on Safari, we shouldn't run into structuredClone() errors due to the FileSystemDirectoryHandles. It also seemed good to rework how we were passing mount options, but there were issues due to progress callbacks making it into postMessage payloads and causing DataCloneErrors. So I'm working on backing those changes out so this can work. |
This PR should be working again in Safari and for local device sites. @adamziel, please let me know if you have any thoughts on this. I'm planning to give this another read tomorrow or Monday and then merge if all is well. |
try { | ||
await playground?.resetVirtualOpfs(); | ||
await clearContentsFromMountDevice(mountDevice); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed this still works.
I reviewed this again and found and fixed an issue with site reset. |
## Motivation for the change, related issues The site switcher was broken by #1669. This PR is a fix for that. Related to #1687 ## Implementation details The site that is booted depends on the redux store, so the current loaded site now depends on redux state. ## Testing Instructions (or ideally a Blueprint) - CI - Use `npm run dev` and manually test switching between sites
Fantastic work here @brandonpayton 🎉 |
Motivation for the change, related issues
Refactors the
remote.html
andworker-thread.ts
boot flows.boot()
method that is strongly typed, accepts the configuration values, and explicitly orchestrates all the boot logic when it is called.This work may eventually enable:
bootWordPress()
on a worker instance.Related to #1398
Follow-up work
bootWordPress()
) on a worker instance instead of the simplifiedboot()
method.Testing Instructions (or ideally a Blueprint)
cc @brandonpayton @bgrgicak