Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions apps/webapp/app/models/member.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,34 @@ export async function provisionMemberDevelopmentEnvironments({
failedProjectId = project.id;
failedProjectIndex = index;

await createEnvironment({
organization,
project,
type: "DEVELOPMENT",
// We set this true but no backfill (yet!?) so never used
// for dev environments
isBranchableEnvironment: true,
member,
maximumConcurrencyLimit,
});
try {
await createEnvironment({
organization,
project,
type: "DEVELOPMENT",
// We set this true but no backfill (yet!?) so never used
// for dev environments
isBranchableEnvironment: true,
member,
maximumConcurrencyLimit,
});
} catch (error) {
// A concurrent accept (double-clicked Accept, a retry, or the recovery
// path overlapping the normal path) can create this member's
// development environment first. The unique constraint on
// (projectId, slug, orgMemberId) then makes our create fail with P2002.
// The environment already exists, so treat the project as provisioned.
if (
error instanceof PrismaNamespace.PrismaClientKnownRequestError &&
error.code === "P2002"
) {
createdProjectIds.push(project.id);
failedProjectId = undefined;
failedProjectIndex = undefined;
continue;
}
throw error;
}

createdProjectIds.push(project.id);
failedProjectId = undefined;
Expand Down