Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
Frando committed Nov 28, 2023
1 parent 90ba6ef commit d948455
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/repco-core/src/util/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import p from 'path'
import { createHash } from 'crypto'
import type { Duplex } from 'stream'
import { Dispatcher } from 'undici'
// @ts-ignore
import { getStatusText } from 'undici/lib/mock/mock-utils.js'

export type CachingDispatcherOpts = {
forward: boolean
Expand Down Expand Up @@ -50,7 +52,7 @@ export class CachingDispatcher extends Dispatcher {
// Not in cache: Forward to outer dispatcher and store result in cache
if (!this.opts.forward) {
// If fowwarding is disabled: Error with 503
if (handlers.onHeaders) handlers.onHeaders(503, [], () => {})
if (handlers.onHeaders) handlers.onHeaders(503, [], () => {}, getStatusText(503))

Check warning on line 55 in packages/repco-core/src/util/fetch.ts

View workflow job for this annotation

GitHub Actions / build-and-test

Insert `⏎·············`
if (handlers.onComplete) handlers.onComplete([])
return
}
Expand All @@ -66,7 +68,7 @@ export class CachingDispatcher extends Dispatcher {
const headers = [...cachedResponse.headers]
headers.push('X-Cache', 'HIT')
if (handlers.onHeaders)
handlers.onHeaders(cachedResponse.status, headers, () => {})
handlers.onHeaders(cachedResponse.status, headers, () => {}, getStatusText(cachedResponse.status))

Check warning on line 71 in packages/repco-core/src/util/fetch.ts

View workflow job for this annotation

GitHub Actions / build-and-test

Replace `cachedResponse.status,·headers,·()·=>·{},·getStatusText(cachedResponse.status)` with `⏎··············cachedResponse.status,⏎··············headers,⏎··············()·=>·{},⏎··············getStatusText(cachedResponse.status),⏎············`
if (handlers.onData) handlers.onData(Buffer.from(cachedResponse.data))
if (handlers.onComplete) handlers.onComplete(cachedResponse.trailers)
}
Expand Down Expand Up @@ -122,7 +124,7 @@ export class DispatchAndCacheHandlers implements Dispatcher.DispatchHandlers {
}
if (this.inner.onHeaders) {
if (stringHeaders) stringHeaders.push('X-Cache', 'MISS')
return this.inner.onHeaders(statusCode, stringHeaders, resume)
return this.inner.onHeaders(statusCode, stringHeaders, resume, getStatusText(statusCode))
}
return false
}
Expand Down

0 comments on commit d948455

Please sign in to comment.