Skip to content

Commit

Permalink
🐛 fix: cleanDataV1
Browse files Browse the repository at this point in the history
  • Loading branch information
yunsii committed Mar 22, 2024
1 parent 567f7e9 commit f1a8d55
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
6 changes: 1 addition & 5 deletions src/worker/_helpers/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,12 @@ export async function upsertKvStore(value: DataV1 | null, allMonitors: Monitor[]
await KV_STORE.delete(DATA_KEY)
return
}
const cleanedValue = cleanDataV1(value, allMonitors)
// eslint-disable-next-line no-console
console.log('🚀 ~ file: store.ts:76 ~ upsertKvStore ~ cleanedValue:', cleanedValue)
const cleanedValue = await cleanDataV1(value, allMonitors)
await KV_STORE.put(DATA_KEY, JSON.stringify(cleanedValue))
}

export async function cleanDataV1(value: DataV1, allMonitors: Monitor[]) {
const { bytes } = memorySizeOf(JSON.stringify(value))
// eslint-disable-next-line no-console
console.debug('value bytes', bytes)

// https://developers.cloudflare.com/kv/platform/limits/
// Value max size 25 MiB, in case of exceptions, we clean data when bytes bigger than 24 MiB.
Expand Down
1 change: 0 additions & 1 deletion src/worker/cron/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export async function handleCronTrigger(event: FetchEvent) {
subrequests.required()
const checkDay = getDate()
const { kvData } = await getStore()
console.log('🚀 ~ file: index.ts:24 ~ handleCronTrigger ~ kvData:', kvData)
subrequests.required()

const { uncheckMonitors, lastCheckedMonitorIds, allMonitors } = await prepareMonitors()
Expand Down

0 comments on commit f1a8d55

Please sign in to comment.