refactor(server): remove directory check option

This commit is contained in:
Brendonovich
2026-09-25 06:39:10 +00:00
parent fdc3eddc8a
commit 10489b2c8b
5 changed files with 7 additions and 20 deletions
+3 -7
View File
@@ -20,19 +20,15 @@ const instances = makeGlobalNode({
deps: [LocationServiceMap.node],
})
export function build<A, E>(
root: LayerNode.Graph<A, E>,
replacements: LayerNode.Replacements = [],
options: { directoryCheck?: boolean } = {},
) {
export function build<A, E>(root: LayerNode.Graph<A, E>, replacements: LayerNode.Replacements = []) {
const bindings = [Instance.node.replace(instances), ...replacements]
return LayerNode.compile(root, {
replacements: [
LocationServiceMap.node.replace(
makeGlobalNode({
service: LocationServiceMap.Service,
layer: buildLocationServiceMap(bindings, options),
deps: options.directoryCheck ? [FSUtil.node] : [],
layer: buildLocationServiceMap(bindings),
deps: [FSUtil.node],
}),
),
...bindings,
+2 -7
View File
@@ -26,14 +26,12 @@ export class PermissionDeniedError extends Error {
export function buildLocationServiceMap(
replacements: LayerNode.Replacements = [],
options: { directoryCheck?: boolean } = {},
): Layer.Layer<LocationServiceMap.Service> {
return Layer.effect(
LocationServiceMap.Service,
Effect.gen(function* () {
const owner = yield* Effect.scope
const fs = options.directoryCheck ? yield* Effect.serviceOption(FSUtil.Service) : Option.none<FSUtil.Interface>()
if (options.directoryCheck && Option.isNone(fs)) return yield* Effect.die("Directory check requires FSUtil")
const fs = yield* Effect.serviceOption(FSUtil.Service)
const builds = MutableHashMap.empty<Location.Ref, { close?: Effect.Effect<void> }>()
const inner: LayerMap.LayerMap<Location.Ref, LocationServices> = yield* LayerMap.make(
(ref: Location.Ref) => {
@@ -41,10 +39,7 @@ export function buildLocationServiceMap(
MutableHashMap.set(builds, ref, build)
return Layer.fromBuild((memoMap, scope) =>
Effect.suspend(() =>
(!options.directoryCheck || ref.workspaceID || Option.isNone(fs)
? Effect.void
: checkDirectory(fs.value, ref)
).pipe(
(ref.workspaceID || Option.isNone(fs) ? Effect.void : checkDirectory(fs.value, ref)).pipe(
Effect.orDie,
Effect.andThen(Layer.buildWithMemoMap(Instance.layer(ref, { replacements: bindings }), memoMap, scope)),
),
-2
View File
@@ -41,8 +41,6 @@ export const ServerOptions = Schema.Struct({
Schema.Struct({
filewatcher: Schema.optional(Schema.Boolean),
fff: Schema.optional(Schema.Boolean),
// Hosts without a local project filesystem (e.g. workerd) opt out of the request-time directory probe.
directoryCheck: Schema.optional(Schema.Boolean),
}),
),
})
+1 -3
View File
@@ -148,9 +148,7 @@ function makeRoutes<AuthError, AuthServices>(
...(instances ? [Instance.node.replace(instances(() => replacements))] : []),
...overrides,
]
return AppNodeBuilder.build(applicationServices, replacements, {
directoryCheck: options.fs?.directoryCheck !== false && !options.simulation,
})
return AppNodeBuilder.build(applicationServices, replacements)
}
const serviceLayer = options.simulation
? Layer.unwrap(
+1 -1
View File
@@ -62,7 +62,7 @@ export function serverOptions(options: Options): ServerOptions {
return {
app: options.app,
password: options.password,
fs: { filewatcher: false, fff: false, directoryCheck: false },
fs: { filewatcher: false, fff: false },
// Durable event history is how a turn orphaned by eviction is recovered:
// the boot-time resume replays it. A runtime that dies without teardown
// cannot opt out of it, so this is not exposed as an option.