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

feat: cache etag support #3758

Merged
merged 5 commits into from
Nov 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup
Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com>
  • Loading branch information
flakey5 committed Nov 18, 2024
commit abc7f1d22170b80d75ae686a2a70d83ee27a9baf
2 changes: 2 additions & 0 deletions test/interceptors/cache.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict'

Check failure on line 1 in test/interceptors/cache.js

GitHub Actions / test (20, ubuntu-latest) / Test with Node.js 20 on ubuntu-latest

test/interceptors/cache.js

[Error [ERR_TEST_FAILURE]: test timed out after 30000ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 30000ms' }

Check failure on line 1 in test/interceptors/cache.js

GitHub Actions / test (23, ubuntu-latest) / Test with Node.js 23 on ubuntu-latest

test/interceptors/cache.js

[Error [ERR_TEST_FAILURE]: test timed out after 30000ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 30000ms' }

Check failure on line 1 in test/interceptors/cache.js

GitHub Actions / test (21, ubuntu-latest) / Test with Node.js 21 on ubuntu-latest

test/interceptors/cache.js

[Error [ERR_TEST_FAILURE]: test timed out after 30000ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 30000ms' }

Check failure on line 1 in test/interceptors/cache.js

GitHub Actions / test (22, ubuntu-latest) / Test with Node.js 22 on ubuntu-latest

test/interceptors/cache.js

[Error [ERR_TEST_FAILURE]: test timed out after 30000ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 30000ms' }

Check failure on line 1 in test/interceptors/cache.js

GitHub Actions / test (18, ubuntu-latest) / Test with Node.js 18 on ubuntu-latest

test/interceptors/cache.js

[Error [ERR_TEST_FAILURE]: test timed out after 30000ms] { failureType: 'testTimeoutFailure', cause: 'test timed out after 30000ms', code: 'ERR_TEST_FAILURE' }

Check failure on line 1 in test/interceptors/cache.js

GitHub Actions / test (23, macos-latest) / Test with Node.js 23 on macos-latest

test/interceptors/cache.js

[Error [ERR_TEST_FAILURE]: test timed out after 30000ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 30000ms' }

Check failure on line 1 in test/interceptors/cache.js

GitHub Actions / test (22, macos-latest) / Test with Node.js 22 on macos-latest

test/interceptors/cache.js

[Error [ERR_TEST_FAILURE]: test timed out after 30000ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 30000ms' }

Check failure on line 1 in test/interceptors/cache.js

GitHub Actions / test (20, macos-latest) / Test with Node.js 20 on macos-latest

test/interceptors/cache.js

[Error [ERR_TEST_FAILURE]: test timed out after 30000ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 30000ms' }

Check failure on line 1 in test/interceptors/cache.js

GitHub Actions / test (21, macos-latest) / Test with Node.js 21 on macos-latest

test/interceptors/cache.js

[Error [ERR_TEST_FAILURE]: test timed out after 30000ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 30000ms' }

Check failure on line 1 in test/interceptors/cache.js

GitHub Actions / test (18, macos-latest) / Test with Node.js 18 on macos-latest

test/interceptors/cache.js

[Error [ERR_TEST_FAILURE]: test timed out after 30000ms] { failureType: 'testTimeoutFailure', cause: 'test timed out after 30000ms', code: 'ERR_TEST_FAILURE' }

Check failure on line 1 in test/interceptors/cache.js

GitHub Actions / Test with Node.js 20 compiled --without-intl

test/interceptors/cache.js

[Error [ERR_TEST_FAILURE]: test timed out after 30000ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 30000ms' }

Check failure on line 1 in test/interceptors/cache.js

GitHub Actions / Test with Node.js 23 compiled --without-intl

test/interceptors/cache.js

[Error [ERR_TEST_FAILURE]: test timed out after 30000ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 30000ms' }

Check failure on line 1 in test/interceptors/cache.js

GitHub Actions / Test with Node.js 22 compiled --without-intl

test/interceptors/cache.js

[Error [ERR_TEST_FAILURE]: test timed out after 30000ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 30000ms' }

const { describe, test, after } = require('node:test')
const { strictEqual, notEqual, fail, equal } = require('node:assert')
@@ -229,13 +229,14 @@
const clock = FakeTimers.install({
shouldClearNativeTimers: true
})
tick(0)

const server = createServer((req, res) => {
res.setHeader('cache-control', 'public, s-maxage=1, stale-while-revalidate=10')
requestsToOrigin++

if (requestsToOrigin > 1) {
equal(req.headers['etag'], '"asd123"')

Check failure on line 239 in test/interceptors/cache.js

GitHub Actions / test (21, ubuntu-latest) / Test with Node.js 21 on ubuntu-latest

revalidates request w/ etag when provided

Error [ERR_TEST_FAILURE]: undefined == '"asd123"' at process.emit (node:events:519:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: undefined == '"asd123"' at Server.<anonymous> (/home/runner/work/undici/undici/test/interceptors/cache.js:239:9) at Server.emit (node:events:519:28) at parserOnIncoming (node:_http_server:1137:12) at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17) { generatedMessage: true, code: 'ERR_ASSERTION', actual: undefined, expected: '"asd123"', operator: '==' } }

Check failure on line 239 in test/interceptors/cache.js

GitHub Actions / test (18, ubuntu-latest) / Test with Node.js 18 on ubuntu-latest

revalidates request w/ etag when provided

Error [ERR_TEST_FAILURE]: undefined == '"asd123"' at process.emit (node:events:517:28) { failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: undefined == '"asd123"' at Server.<anonymous> (/home/runner/work/undici/undici/test/interceptors/cache.js:239:9) at Server.emit (node:events:517:28) at parserOnIncoming (node:_http_server:1130:12) at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17) { generatedMessage: true, code: 'ERR_ASSERTION', actual: undefined, expected: '"asd123"', operator: '==' }, code: 'ERR_TEST_FAILURE' }

Check failure on line 239 in test/interceptors/cache.js

GitHub Actions / test (21, macos-latest) / Test with Node.js 21 on macos-latest

revalidates request w/ etag when provided

Error [ERR_TEST_FAILURE]: undefined == '"asd123"' at process.emit (node:events:519:28) { code: 'ERR_TEST_FAILURE', failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: undefined == '"asd123"' at Server.<anonymous> (/Users/runner/work/undici/undici/test/interceptors/cache.js:239:9) at Server.emit (node:events:519:28) at parserOnIncoming (node:_http_server:1137:12) at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17) { generatedMessage: true, code: 'ERR_ASSERTION', actual: undefined, expected: '"asd123"', operator: '==' } }

Check failure on line 239 in test/interceptors/cache.js

GitHub Actions / test (18, macos-latest) / Test with Node.js 18 on macos-latest

revalidates request w/ etag when provided

Error [ERR_TEST_FAILURE]: undefined == '"asd123"' at process.emit (node:events:517:28) { failureType: 'uncaughtException', cause: AssertionError [ERR_ASSERTION]: undefined == '"asd123"' at Server.<anonymous> (/Users/runner/work/undici/undici/test/interceptors/cache.js:239:9) at Server.emit (node:events:517:28) at parserOnIncoming (node:_http_server:1130:12) at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17) { generatedMessage: true, code: 'ERR_ASSERTION', actual: undefined, expected: '"asd123"', operator: '==' }, code: 'ERR_TEST_FAILURE' }

if (requestsToOrigin === 3) {
res.end('asd123')
@@ -274,6 +275,7 @@
strictEqual(await response.body.text(), 'asd')

clock.tick(1500)
tick(1500)

// Now we send two more requests. Both of these should reach the origin,
// but now with a conditional header asking if the resource has been
Loading