Skip to content

Commit

Permalink
add timeout for realm readiness
Browse files Browse the repository at this point in the history
  • Loading branch information
habdelra committed May 15, 2024
1 parent 0b445ee commit ca40a37
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/runtime-common/realm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,21 @@ export class Realm {
if (!isLocal) {
// allow any WIP index requests to query the index while it's building up
if (!request.headers.get('X-Boxel-Use-WIP-Index')) {
await this.ready;
let timeout = await Promise.race<void | Error>([
this.ready,
new Promise((r) =>
setTimeout(() => {
r(
new Error(
`Timeout waiting for realm ${this.url} to become ready`,
),
);
}, 60 * 1000),
),
]);
if (timeout) {
return new Response(timeout.message, { status: 500 });
}
}

let isWrite = ['PUT', 'PATCH', 'POST', 'DELETE'].includes(
Expand Down

0 comments on commit ca40a37

Please sign in to comment.