fix cpu limit exceeded, update README

This commit is contained in:
lyc8503 committed 2024-01-30 14:06:21 +08:00
1 parent 31a4d9345a
commit 092140b962
3 files changed
+13 -5

No files matched your search

+10 -3
View File
@@ -13,12 +13,17 @@ export const runtime = 'experimental-edge'
const inter = Inter({ subsets: ['latin'] })
export default function Home({
state,
state: stateStr,
monitors,
}: {
state: MonitorState
state: string
monitors: MonitorTarget[]
}) {
let state;
if (stateStr !== undefined) {
state = JSON.parse(stateStr) as MonitorState
}
return (
<>
<Head>
@@ -70,7 +75,9 @@ export async function getServerSideProps() {
const { UPTIMEFLARE_STATE } = process.env as unknown as {
UPTIMEFLARE_STATE: KVNamespace
}
const state = (await UPTIMEFLARE_STATE?.get('state', 'json')) as unknown as MonitorState
// Read state as string from KV, to avoid hitting server-side cpu time limit
const state = (await UPTIMEFLARE_STATE?.get('state')) as unknown as MonitorState
// Only present these values to client
const monitors = workerConfig.monitors.map((monitor) => {