Skip to content

Commit 01feba1

Browse files
committed
fix(api): refresh state before port proxy project lookup
1 parent 36a68cb commit 01feba1

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

packages/api/src/services/project-port-proxy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import * as HttpServerRequest from "@effect/platform/HttpServerRequest"
44
import * as HttpServerError from "@effect/platform/HttpServerError"
55
import * as HttpServerResponse from "@effect/platform/HttpServerResponse"
66
import type { PlatformError } from "@effect/platform/Error"
7-
import { listProjectItems } from "@effect-template/lib"
87
import type { ListProjectsContext } from "@effect-template/lib/usecases/projects-list"
98
import { Effect } from "effect"
109
import * as Stream from "effect/Stream"
1110

1211
import { ApiBadRequestError, ApiConflictError, ApiInternalError, ApiNotFoundError } from "../api/errors.js"
1312
import { listProjectPortForwards } from "./project-port-forwards.js"
13+
import { readProjectItemsForInventory } from "./projects.js"
1414
import {
1515
normalizeForwardedPrefix,
1616
parseLinuxDefaultGatewayIp,
@@ -134,13 +134,13 @@ const fetchUpstream = (
134134

135135
const resolveProxyProjectId = (
136136
target: ProjectPortProxyPath
137-
): Effect.Effect<string, ApiConflictError | ApiNotFoundError | PlatformError, ListProjectsContext> => {
137+
): Effect.Effect<string, ApiConflictError | ApiInternalError | ApiNotFoundError, ListProjectsContext> => {
138138
if (target._tag === "ProjectId") {
139139
return Effect.succeed(target.projectId)
140140
}
141141

142142
return Effect.gen(function*(_) {
143-
const projects = yield* _(listProjectItems)
143+
const projects = yield* _(readProjectItemsForInventory())
144144
const matches = projects.filter((project) => projectShortKey(project.projectDir) === target.projectKey)
145145
if (matches.length === 0) {
146146
return yield* _(Effect.fail(new ApiNotFoundError({ message: `Project key not found: ${target.projectKey}` })))

packages/api/src/services/projects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ const toProjectInventoryReadError = (error: unknown): ApiInternalError =>
248248
// COMPLEXITY: O(git pull)
249249
export const refreshProjectStateForInventory = () => autoPullState
250250

251-
const readProjectItemsForInventory = () =>
251+
export const readProjectItemsForInventory = () =>
252252
refreshProjectStateForInventory().pipe(
253253
Effect.zipRight(listProjectItems),
254254
Effect.mapError(toProjectInventoryReadError)

0 commit comments

Comments
 (0)