Skip to content

Commit 7552090

Browse files
authored
fix: use a 90 seconds timeout to prevent Cloudflare from timing out (#3160)
1 parent fc4effb commit 7552090

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/runtime/internal/database.server.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ export async function checkAndImportDatabaseIntegrity(event: H3Event, collection
6060
}
6161
}
6262

63+
/**
64+
* Timeout for waiting for another request to finish the database initialization
65+
*/
66+
const REQUEST_TIMEOUT = 90
67+
6368
async function _checkAndImportDatabaseIntegrity(event: H3Event, collection: string, integrityVersion: string, config: RuntimeConfig['content']) {
6469
const db = loadDatabaseAdapter(config)
6570

@@ -95,7 +100,7 @@ async function _checkAndImportDatabaseIntegrity(event: H3Event, collection: stri
95100

96101
// after timeout is reached, give up and stop the query
97102
// it has to be that initialization has failed
98-
if (iterationCount++ > 300) {
103+
if (iterationCount++ > REQUEST_TIMEOUT) {
99104
clearInterval(interval)
100105
reject(new Error('Waiting for another database initialization timed out'))
101106
}

0 commit comments

Comments
 (0)