Skip to content
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

src: fix symlink issue, subtitution middleware hack #223

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

flakey5
Copy link
Member

@flakey5 flakey5 commented Dec 21, 2024

Main changes:

  • Adds build-r2-symlinks.mjs script
    • Replaces update-redirect-links.json, still creates latestVersion.json
    • src/constants/docsDirectory.json - cache of folders that exist in nodejs/docs/ so we can access them in the worker w/o the latency of another R2 call
    • src/constants/cachedDirectories.json - cache of the directory listings for nodejs/release/ and nodejs/docs/ with the symlinks added
  • Fixed the temp hack that we had for the substitution middleware

Misc changes:

  • Removed promote-release.mjs (unused)
  • Renamed compile-handlebars.js to be an .mjs file
  • Fixed typo w/ Request.unsubstitutedUrl

Fixes #163

@flakey5 flakey5 requested a review from a team as a code owner December 21, 2024 07:51
tests/e2e/directory.test.ts Outdated Show resolved Hide resolved
Signed-off-by: flakey5 <[email protected]>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is the built file?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why this cannot be inside the cachedDirectories folder? To reuse same logic and reduce the need of maintaining two different files and have centralised logic?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but it would mean that we'd need to store symlinks separately from the real files (something like

interface CachedDirectory {
  subdirectories: string[],
  symlinkSubdirectories: string[],
  files: File[],
  symlinkFiles: File[]
}

).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very interesting. I wonder if this will be cached between workers so that it doesn't need to be read on every network request? I also wonder if somehow this gets cached or whatnot 🤔

Because I assume this file will keep increasing over time. We might want to consider using Git LFS to also prevent these files to be shown on diff.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this will be cached between workers

As in the contents of cachedDirectories.json? It's inlined along with the rest of the source files for the worker, so it's stored in-memory for each instance of the worker.

// of it below
const result: ReadDirectoryResult = CACHED_DIRECTORIES[path];

for (const file of result.files) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, can you do this?:

const result = JSON.parse(input, function(key, value) {
    if (key == 'date') return new Date(Date.parse(value));
    return value;
});

Or something of sort? This speeds up the process and reduces the need of iterating everything again

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since CACHED_DIRECTORIES is already an object I don't think so?

Copy link
Member

@ovflowd ovflowd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a first-pass comment, but it looks good so far. I left a few comments, and I plan to make another in-depth review later!

Signed-off-by: flakey5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue with symlinks
2 participants