Skip to content

Commit

Permalink
Clear inflight requests
Browse files Browse the repository at this point in the history
  • Loading branch information
erxclau committed Nov 28, 2024
1 parent 1481902 commit 9f6f0c9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/handler/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import { createLRU, parseViewBox } from '../utils.js'

type ResolvedImageData = [string, number?, number?] | readonly []
export const cache = createLRU<ResolvedImageData>(100)
const inflightRequests = new Map<string, Promise<ResolvedImageData>>()
export const inflightRequests = new Map<string, Promise<ResolvedImageData>>()

const ALLOWED_IMAGE_TYPES = [PNG, APNG, JPEG, GIF, SVG]

Expand Down
3 changes: 2 additions & 1 deletion src/satori.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { segment } from './utils.js'
import { detectLanguageCode, LangCode, Locale } from './language.js'
import getTw from './handler/tailwind.js'
import { preProcessNode } from './handler/preprocess.js'
import { cache } from './handler/image.js'
import { cache, inflightRequests } from './handler/image.js'

// We don't need to initialize the opentype instances every time.
const fontCache = new WeakMap()
Expand Down Expand Up @@ -90,6 +90,7 @@ export default async function satori(
const processedWordsMissingFonts = new Set()

cache.clear()
inflightRequests.clear()
await preProcessNode(element)

const handler = layout(element, {
Expand Down

0 comments on commit 9f6f0c9

Please sign in to comment.