Skip to content

Commit

Permalink
fix: type
Browse files Browse the repository at this point in the history
  • Loading branch information
07akioni committed Jul 25, 2024
1 parent 23d39e0 commit 99b0fb0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 6 additions & 4 deletions packages/node/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ export const adapter: LylaAdapter<LylaAdapterMeta> = ({
protocol: parsedUrl.protocol
},
(incomingMessage) => {
onHeadersReceived(
ensureResponseHeaders(incomingMessage.headers),
clientRequest
)
if (onHeadersReceived) {
onHeadersReceived(
ensureResponseHeaders(incomingMessage.headers),
clientRequest
)
}
const rawResponseContentLength = incomingMessage.headers['content-length']
const responseContentLength =
typeof rawResponseContentLength === 'string' &&
Expand Down
4 changes: 2 additions & 2 deletions packages/universal/src/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const { lyla, isLylaError } = coreCreateLyla<undefined, LylaAdapterMeta>(
withCredentials,
extraOptions,
onHeadersReceived(headers, originalRequest) {
return onHeadersReceived(headers, {
return onHeadersReceived?.(headers, {
anyhow: originalRequest,
node: originalRequest,
web: undefined
Expand Down Expand Up @@ -118,7 +118,7 @@ export const { lyla, isLylaError } = coreCreateLyla<undefined, LylaAdapterMeta>(
withCredentials,
extraOptions,
onHeadersReceived(headers, originalRequest) {
return onHeadersReceived(headers, {
return onHeadersReceived?.(headers, {
anyhow: originalRequest,
node: undefined,
web: originalRequest
Expand Down
4 changes: 3 additions & 1 deletion packages/web/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ export const adapter: LylaAdapter<LylaAdapterMeta> = ({
})
const _onHeadersReceived = () => {
if (xhr.readyState === xhr.HEADERS_RECEIVED) {
onHeadersReceived(ensureResponseHeaders(), xhr)
if (onHeadersReceived) {
onHeadersReceived(ensureResponseHeaders(), xhr)
}
}
xhr.removeEventListener('readystatechange', _onHeadersReceived)
}
Expand Down

0 comments on commit 99b0fb0

Please sign in to comment.