Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

More cache fixes #3955

Merged
merged 3 commits into from
Dec 18, 2024
Merged

More cache fixes #3955

merged 3 commits into from
Dec 18, 2024

Conversation

flakey5
Copy link
Member

@flakey5 flakey5 commented Dec 17, 2024

  • Spec compliant http date parsing
    • Also fixes invalid (NaN) values in dates just being defaulted (ex/ for new Date('Wed, aa Dec 2024 23:20:57 GMT'), the day defaults to 1 instead of it being marked as an invalid date)
    • Performance is about the same, still might be some room for optimization
  • Heuristic caching based on last-modified
  • Rewrote the cache test suite runner
    • Runs each environment in a child process now because the suite doesn't really like being ran multiple times in the same process
    • These are also now ran in CI
  • Adds CI job to update the cache tests automatically
  • Strips the cache test suite down to just what we need to run them + tell if a test is broken

With this, we're passing 65% of the tests in the suite. The two main behaviors that are left are invalidating the urls given in the Location header and some behaviors regarding status codes other than 200 and 307 (note these are still optional)

cc @mcollina

Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com>
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

The cache tests are not run automatically yet as part of CI, right? Can you add them (and maybe flag the failing ones as expected failures, or just implement those behaviors)?

.github/workflows/update-cache-tests.yml Outdated Show resolved Hide resolved
lib/handler/cache-handler.js Outdated Show resolved Hide resolved
Comment on lines +202 to +203
// TODO (fix): Should we resume even if was paused downstream?
controller.resume()
Copy link
Member

Choose a reason for hiding this comment

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

Let's aim to keep it in sync with the controller as possible; at the end it is what allow to apply back pressure while consuming the body

this.#writeStream
.on('drain', () => controller.resume())
.on('error', function () {
// TODO (fix): Make error somehow observable?
Copy link
Member

Choose a reason for hiding this comment

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

If we cannot store the response's body, best will be to just handover the body to the caller and fail silently; I'm thinking on some sort of on error event here?

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'm thinking on some sort of on error event here?

Where would this be?

Copy link
Member

Choose a reason for hiding this comment

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

Good question; maybe the cache-handler itself? I believe we do not have reference to the dispatcher at this point but the dispatch method.

Copy link
Member

Choose a reason for hiding this comment

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

Let's explore it in further PR

lib/util/date.js Outdated Show resolved Hide resolved
flakey5 and others added 2 commits December 17, 2024 11:25
Co-authored-by: Carlos Fuentes <me@metcoder.dev>
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit 6569585 into nodejs:main Dec 18, 2024
31 checks passed
@github-actions github-actions bot mentioned this pull request Dec 18, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants