GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [http-cache] follow up by Uzlopak · Pull Request #3733 · nodejs/undici

Conversation

@Uzlopak

@Uzlopak Uzlopak commented Oct 14, 2024

Copy link
Copy Markdown
Contributor

follow up of http-cache pr

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Uzlopak
followup http-cache
c65844d
@Uzlopak
Uzlopak force-pushed the followup-http-cache branch from 08bfb82 to c65844d Compare October 14, 2024 19:19
Uzlopak added 4 commits October 14, 2024 21:25
@Uzlopak
fix methods check
10755d3
@Uzlopak
avoid instantiation in case of error
9a8b0b4
@Uzlopak
improve
bc5cfe7
@Uzlopak
rename assertCacheStoreType to assertCacheStore
310c2e5
@Uzlopak
Uzlopak requested review from metcoder95 and ronag and removed request for ronag October 14, 2024 20:07
@Uzlopak
remove validation
a5fd832
Uzlopak
Uzlopak commented Oct 14, 2024
View reviewed changes
Comment thread lib/handler/cache-handler.js

if (
UNSAFE_METHODS.includes(this.#req.method) &&
!this.#methods.includes(this.#requestOptions.method) &&

@Uzlopak Uzlopak Oct 14, 2024

Copy link
Copy Markdown
Contributor Author

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.

WHy did we check for unsafe methods? this whole if condition seems actually kind of dubious.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Uzlopak Uzlopak Oct 14, 2024

Copy link
Copy Markdown
Contributor Author

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.

@flakey5

The invalidation logic is kind of strange. Also what is the point of passing methods, when they are ignored anyway? So I guess actually methods would have been an array of safe methods?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Uzlopak Uzlopak Oct 14, 2024

Copy link
Copy Markdown
Contributor Author

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.

A cache MUST invalidate the target URI (Section 7.1 of [HTTP]) when it receives a non-error status code in response to an unsafe request method (including methods whose safety is unknown).

So I guess my proposed change should be right, as the passed methods will be considered safe methods. Especially in regard of the last sentence in the spec, that methods whose safety is unknown is also covered.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Uzlopak added 3 commits October 14, 2024 22:17
@Uzlopak
remove fallback
85727cf
@Uzlopak
fix
bff7c42
@Uzlopak
fix
6a099bb
Uzlopak
Uzlopak commented Oct 14, 2024
View reviewed changes
Comment thread lib/interceptor/cache.js
Comment on lines -38 to -39
// Safe methods the user wants and unsafe methods
const methods = [...globalOpts.methods, ...UNSAFE_METHODS]

@Uzlopak Uzlopak Oct 14, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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.

why did we "mixed" with unsafe methods?

this would result in caching unsafe requests

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@flakey5 flakey5 Oct 15, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

this allows requests with unsafe methods to get to the cache handler, where they'll cause a cache purge if the response is a success

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Uzlopak
Uzlopak requested a review from mcollina October 14, 2024 20:48
@Uzlopak

Uzlopak commented Oct 14, 2024

Copy link
Copy Markdown
Contributor Author

@flakey5 PTAL

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Uzlopak Uzlopak changed the title followup http-cache [http-cache] follow up Oct 14, 2024
metcoder95
metcoder95 approved these changes Oct 15, 2024
View reviewed changes
@Uzlopak
Uzlopak merged commit 68107da into main Oct 15, 2024
@Uzlopak
Uzlopak deleted the followup-http-cache branch October 15, 2024 21:55
flakey5 added a commit to flakey5/undici that referenced this pull request Oct 16, 2024
@flakey5
fix: unsafe methods not causing cache purge
f221380
Fixes bug introduced in nodejs#3733 where unsafe methods no longer make it to
the cache handler and cause a cache purge for an origin.

Also removes a duplicate test file.

Signed-off-by: flakey5 <[email protected]>
@flakey5 flakey5 mentioned this pull request Oct 16, 2024
fix: unsafe methods not causing cache purge #3739
Merged
Uzlopak pushed a commit that referenced this pull request Oct 19, 2024
@flakey5
fix: unsafe methods not causing cache purge (#3739)
3030506
* fix: unsafe methods not causing cache purge

Fixes bug introduced in #3733 where unsafe methods no longer make it to
the cache handler and cause a cache purge for an origin.

Also removes a duplicate test file.

Signed-off-by: flakey5 <[email protected]>

* Update cache.js

* extend test to check that safe methods we're not caching don't purge the
cache

Signed-off-by: flakey5 <[email protected]>

* code review

Signed-off-by: flakey5 <[email protected]>

---------

Signed-off-by: flakey5 <[email protected]>
@github-actions github-actions Bot mentioned this pull request Dec 3, 2024
[Release] v7.1.0 #3922
Merged
This was referenced Dec 16, 2024
[Release] v7.1.1 #3952
Closed
[Release] v7.2.0 #3962
Merged
@svc-secops svc-secops mentioned this pull request Jan 19, 2025
fix(deps): update dependency undici to v7 - autoclosed apollographql/vscode-graphql#241
Closed
@github-actions github-actions Bot mentioned this pull request Mar 12, 2025
[Release] v6.21.2 #4092
Closed
@github-actions github-actions Bot mentioned this pull request May 12, 2025
[Release] v6.21.3 #4211
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@metcoder95 metcoder95 metcoder95 approved these changes
@ronag ronag Awaiting requested review from ronag
@mcollina mcollina Awaiting requested review from mcollina
+1 more reviewer
@flakey5 flakey5 flakey5 left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@Uzlopak @metcoder95 @flakey5
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.