Problem/Motivation
When a path is processed by the tome generator, any files (JS, CSS, images) attached are copies from their original location into the staging area for the preview site.
For a non trivial node (e.g. a page with a complex react application) this could result in one path requiring 100 files to be copied.
On a distributed file system like EFS, copying 100 files as well as any other processing for that path may not complete in the allowed timeout for a single request
Steps to reproduce
Configure local host to have a 60s timeout
Edit tome's static generator class's copyPath method to add a 300ms sleep after each file copy to emulate latency seen in a distributed file system
Attempt to generate a preview for a piece of content with a complex FE component/ React app
Experience timeout
Proposed resolution
We already sub-class tome's static generator and have an implementation of copyPaths that tracks copied files.
Instead of calling the parent in this method, push the file paths to the build.
Have the deploy process deploy them from the original file instead of a copied version
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #31 | 3271913-31.patch | 31.63 KB | larowlan |
| #31 | 3271913-interdiff-31.txt | 783 bytes | larowlan |
| #20 | 3271913-2-20.patch | 31.03 KB | larowlan |
| #20 | 3271913-20-interdiff.txt | 11.65 KB | larowlan |
| #17 | 3271913-12.patch | 21.42 KB | larowlan |
Issue fork preview_site-3271913
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
dpiTrying to figure out the big picture here.
As far as I can tell its not quite as simple as moving body of the copy operation to a new queue, as the caller relies on the copied file, and recursively looks for more resources within the copied file.
Perhaps
\Drupal\preview_site\Plugin\PreviewSite\Generate\TomeGenerator::generateBuildForPathshould be split at the$remaining_assets = $this->static->exportPaths($invoke_paths);point.Where
\Drupal\tome_static\StaticGenerator::exportPathsbecomes a variable/dynamic size batch recursively copying files.Comment #4
larowlanLooks good, but getting an odd bot failure
Comment #5
acbramley commentedTesting this locally it's deleting css and js files that it copies over.
Comment #6
acbramley commentedWe've been running this in prod for some time and it seems to be working well.
Comment #7
acbramley commentedThis is actually causing massive issues with #3230078: Add support for Javascript modules - if a page contains a javascript file that imports chunks this patch causes some sort of recursion on those chunks adding thousands of files to the export and taking a long time to complete (over an hour up from 5 minutes).
EDIT: The chunked JS files also don't make it to S3
Comment #8
larowlanFirst a re-roll
Comment #10
larowlanComment #11
larowlanNew approach, no interdiff as its a do-over
Comment #13
larowlanComment #14
larowlanComment #15
larowlanAllow for subdirectory on test-bot
Comment #17
larowlanTake two
Comment #18
acbramley commentedThis is almost identical to
deployArtifactCan we reafctor that so it calls this with
FileHelper::getFilePathWithoutSchema($file, $build)as the path?Otherwise looking pretty good, great idea!
Comment #19
larowlanI considered it, but was on the fence, but having another vote for doing it helps sway me towards it. Will do!
Comment #20
larowlanMade that change and fixed some PHPCS while I was at it
Comment #21
mortim07 commentedI mentioned this to @larowlan, but this has also solved OOM issues with the preview site build form - during validation it was validating the entity reference for all artifacts.
Comment #22
larowlanCutting a new release with this
Comment #24
kamil_lw commentedHello,
I'm reopening this issue, because I'm experiencing a PHP Fatal Error.
Here's a part of the stack trace:
I've taken a look at the preview_site module source code, and I indeed can find the "getJavascriptModules()" method definition nowhere in there.
This issue was introduced in the release 1.1.5 of the module.
PS. This is my first time adding a comment in Drupal's issue tracker. Please forgive me if I should have opened a new issue instead.
Comment #25
acbramley commentedYou're right, that function is provided by https://www.drupal.org/project/tome/issues/3230078
I'm surprised tests are passing...
Comment #26
mortim07 commented@acbramley There isn't test coverage for it. Do we remove the patch for now and roll a new release until the dependency is merged in?
Comment #28
acbramley commentedI've reverted the commit and published 1.1.6
Comment #29
mortim07 commentedGreat @acbramley!
Comment #30
larowlanLet's try and push that one forward then
Comment #31
larowlanThe tome issue is fixed/released so here's a new patch with a minimum requirement on that version of tome
Comment #32
acbramley commentedAwesome! RTBC assuming green :)
Comment #34
larowlanRan the tests locally, as something not right with drupalci, the folder is missing 🤔