Skip to content

Commit

Permalink
fix(writeEarlyHints): call callback if not supported too
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 14, 2022
1 parent d58fad8 commit 10eab1b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/utils/response.ts
Expand Up @@ -87,7 +87,12 @@ export function sendStream (event: H3Event, data: any): Promise<void> {
}

export function writeEarlyHints (event: H3Event, links: string | string[], callback?: () => void) {
if (!event.res.socket && !('writeEarlyHints' in event.res)) { return }
if (!event.res.socket && !('writeEarlyHints' in event.res)) {
if (callback) {
callback()
}
return
}

if ('writeEarlyHints' in event.res) {
// @ts-expect-error native node 18 implementation
Expand Down

0 comments on commit 10eab1b

Please sign in to comment.