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 — Multiple fixes for SQLiteStore, enable them in CI (#3881) · nodejs/undici@55ad16f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • nodejs.yml
  • lib/cache
    • sqlite-cache-store.js
  • package.json
  • test/cache-interceptor
    • sqlite-cache-store-tests.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/nodejs.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/nodejs.yml
+25-4Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ jobs:
3737
- name: Checkout
3838
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
3939
with:
40-
persist-credentials: false
40+
persist-credentials: false
4141

4242
- name: Setup Node.js
4343
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
4444
with:
4545
node-version: lts/*
46-
46+
4747
- name: Install dependencies
4848
run: npm install
4949

@@ -170,19 +170,40 @@ jobs:
170170
- name: Checkout
171171
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
172172
with:
173-
persist-credentials: false
173+
persist-credentials: false
174174

175175
- name: Setup Node.js
176176
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
177177
with:
178178
node-version: lts/*
179-
179+
180180
- name: Install dependencies
181181
run: npm install
182182

183183
- name: Run typings tests
184184
run: npm run test:typescript
185185

186+
test-sqlite:
187+
name: Test with SQLite enabled
188+
timeout-minutes: 15
189+
runs-on: ubuntu-latest
190+
steps:
191+
- name: Checkout
192+
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
193+
with:
194+
persist-credentials: false
195+
196+
- name: Setup Node.js
197+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
198+
with:
199+
node-version: 22
200+
201+
- name: Install dependencies
202+
run: npm install
203+
204+
- name: Run typings tests
205+
run: npm run test:sqlite
206+
186207
automerge:
187208
if: >
188209
github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]'
Collapse file

‎lib/cache/sqlite-cache-store.js‎

Copy file name to clipboardExpand all lines: lib/cache/sqlite-cache-store.js
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ class SqliteCacheStore {
274274
value.statusCode,
275275
value.statusMessage,
276276
value.headers ? JSON.stringify(value.headers) : null,
277-
value.etag,
277+
value.etag ? value.etag : null,
278278
value.cachedAt,
279279
value.staleAt,
280280
value.deleteAt,
@@ -316,7 +316,7 @@ class SqliteCacheStore {
316316
}
317317

318318
#prune () {
319-
if (this.#size <= this.#maxCount) {
319+
if (this.size <= this.#maxCount) {
320320
return 0
321321
}
322322

@@ -341,7 +341,7 @@ class SqliteCacheStore {
341341
* Counts the number of rows in the cache
342342
* @returns {Number}
343343
*/
344-
get #size () {
344+
get size () {
345345
const { total } = this.#countEntriesQuery.get()
346346
return total
347347
}
@@ -388,7 +388,7 @@ class SqliteCacheStore {
388388
const vary = JSON.parse(value.vary)
389389

390390
for (const header in vary) {
391-
if (headerValueEquals(headers[header], vary[header])) {
391+
if (!headerValueEquals(headers[header], vary[header])) {
392392
matches = false
393393
break
394394
}
Collapse file

‎package.json‎

Copy file name to clipboardExpand all lines: package.json
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"test:javascript:without-intl": "npm run test:javascript:no-jest",
7474
"test:busboy": "borp -p \"test/busboy/*.js\"",
7575
"test:cache": "borp -p \"test/cache/*.js\"",
76+
"test:sqlite": "NODE_OPTIONS=--experimental-sqlite borp -p \"test/cache-interceptor/*.js\"",
7677
"test:cache-interceptor": "borp -p \"test/cache-interceptor/*.js\"",
7778
"test:cookies": "borp -p \"test/cookie/*.js\"",
7879
"test:eventsource": "npm run build:node && borp --expose-gc -p \"test/eventsource/*.js\"",
Collapse file

‎test/cache-interceptor/sqlite-cache-store-tests.js‎

Copy file name to clipboardExpand all lines: test/cache-interceptor/sqlite-cache-store-tests.js
+48-2Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ test('SqliteCacheStore works nicely with multiple stores', async (t) => {
5252
const requestValue = {
5353
statusCode: 200,
5454
statusMessage: '',
55-
rawHeaders: [Buffer.from('1'), Buffer.from('2'), Buffer.from('3')],
55+
headers: { foo: 'bar' },
5656
cachedAt: Date.now(),
5757
staleAt: Date.now() + 10000,
5858
deleteAt: Date.now() + 20000
@@ -111,7 +111,7 @@ test('SqliteCacheStore maxEntries', async (t) => {
111111
const requestValue = {
112112
statusCode: 200,
113113
statusMessage: '',
114-
rawHeaders: [Buffer.from('1'), Buffer.from('2'), Buffer.from('3')],
114+
headers: { foo: 'bar' },
115115
cachedAt: Date.now(),
116116
staleAt: Date.now() + 10000,
117117
deleteAt: Date.now() + 20000
@@ -125,3 +125,49 @@ test('SqliteCacheStore maxEntries', async (t) => {
125125

126126
strictEqual(store.size <= 11, true)
127127
})
128+
129+
test('two writes', async (t) => {
130+
if (!hasSqlite) {
131+
t.skip()
132+
return
133+
}
134+
135+
const SqliteCacheStore = require('../../lib/cache/sqlite-cache-store.js')
136+
const sqliteLocation = 'cache-interceptor.sqlite'
137+
138+
const store = new SqliteCacheStore({
139+
location: sqliteLocation,
140+
maxCount: 10
141+
})
142+
143+
t.after(async () => {
144+
await rm(sqliteLocation)
145+
})
146+
147+
const request = {
148+
origin: 'localhost',
149+
path: '/',
150+
method: 'GET',
151+
headers: {}
152+
}
153+
154+
const requestValue = {
155+
statusCode: 200,
156+
statusMessage: '',
157+
headers: { foo: 'bar' },
158+
cachedAt: Date.now(),
159+
staleAt: Date.now() + 10000,
160+
deleteAt: Date.now() + 20000
161+
}
162+
const requestBody = ['asd', '123']
163+
164+
{
165+
const writable = store.createWriteStream(request, requestValue)
166+
await once(writeResponse(writable, requestBody), 'close')
167+
}
168+
169+
{
170+
const writable = store.createWriteStream(request, requestValue)
171+
await once(writeResponse(writable, requestBody), 'close')
172+
}
173+
})

0 commit comments

Comments
0 (0)
You are visitor 01402792 — 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.