MCPcopy Create free account
hub / github.com/effect-app/libs / waitForServer

Function waitForServer

repos/effect/packages/sql/libsql/test/util.ts:5–20  ·  view source on GitHub ↗
(container: StartedTestContainer)

Source from the content-addressed store, hash-verified

3import { GenericContainer, type StartedTestContainer } from "testcontainers"
4
5const waitForServer = async (container: StartedTestContainer) => {
6 const url = `http://${container.getHost()}:${container.getMappedPort(8080)}`
7 let error: unknown = undefined
8
9 for (let i = 0; i < 60; i++) {
10 try {
11 await fetch(url)
12 return
13 } catch (cause) {
14 error = cause
15 await new Promise((resolve) => setTimeout(resolve, 250))
16 }
17 }
18
19 throw error
20}
21
22export class LibsqlContainer extends Context.Service<
23 LibsqlContainer,

Callers 1

LibsqlContainerClass · 0.85

Calls 1

fetchFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…