Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions packages/cache/src/bootstrap/cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,7 @@ describe('Cache API', () => {
})
const cache = new NetlifyCache({
base64Encode,
getContext: () => ({ host, token, url }),
logger,
getContext: () => ({ host, logger, token, url }),
name: 'my-cache',
userAgent,
})
Expand Down
6 changes: 2 additions & 4 deletions packages/cache/src/bootstrap/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ const serializeResourceHeaders = Symbol('serializeResourceHeaders')
export class NetlifyCache implements Cache {
#base64Encode: Base64Encoder
#getContext: RequestContextFactory
#logger?: Logger
#name: string
#userAgent?: string

constructor({ base64Encode, getContext, logger, name, userAgent }: NetlifyCacheOptions) {
constructor({ base64Encode, getContext, name, userAgent }: NetlifyCacheOptions) {
this.#base64Encode = base64Encode
this.#getContext = getContext
this.#logger = logger
this.#name = name
this.#userAgent = userAgent
}
Expand Down Expand Up @@ -185,7 +183,7 @@ export class NetlifyCache implements Cache {
const errorDetail = cacheResponse.headers.get(HEADERS.ErrorDetail) ?? ''
const errorMessage = ERROR_CODES[errorDetail as keyof typeof ERROR_CODES] || GENERIC_ERROR

this.#logger?.(`Failed to write to the cache: ${errorMessage}`)
context.logger?.(`Failed to write to the cache: ${errorMessage}`)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cache/src/bootstrap/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export type Logger = (...args: any[]) => void
export interface EnvironmentOptions {
base64Encode: Base64Encoder
getContext: RequestContextFactory
logger?: Logger
userAgent?: string
}

Expand All @@ -19,6 +18,7 @@ export type RequestContextFactory = (options: { operation: Operation }) => Reque

export interface RequestContext {
host: string
logger?: Logger
token: string
url: string
}
Loading