Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 9 additions & 5 deletions src/lib/init/local-ops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import type {
ApplyPatchsetPatch,
ApplyPatchsetPayload,
CreateSentryProjectPayload,
DetectSentryPayload,
DirEntry,
FileExistsBatchPayload,
GlobPayload,
Expand Down Expand Up @@ -440,7 +439,7 @@ export async function handleLocalOp(
case "create-sentry-project":
return await createSentryProject(payload, options);
case "detect-sentry":
return await detectSentry(payload);
return await precomputeSentryDetection(payload.cwd);
default:
return {
ok: false,
Expand Down Expand Up @@ -990,11 +989,16 @@ export async function detectExistingProject(cwd: string): Promise<{
return null;
}

async function detectSentry(
payload: DetectSentryPayload
/**
* Detect existing Sentry setup in a directory. Exported so wizard-runner
* can pre-compute this alongside dirListing before the workflow starts,
* eliminating a suspend/resume roundtrip.
*/
export async function precomputeSentryDetection(
cwd: string
): Promise<LocalOpResult> {
const { detectDsn } = await import("../dsn/index.js");
const dsn = await detectDsn(payload.cwd);
const dsn = await detectDsn(cwd);

if (!dsn) {
return { ok: true, data: { status: "none", signals: [] } };
Expand Down
7 changes: 6 additions & 1 deletion src/lib/init/wizard-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
detectExistingProject,
handleLocalOp,
precomputeDirListing,
precomputeSentryDetection,
preReadCommonFiles,
resolveOrgSlug,
tryGetExistingProject,
Expand Down Expand Up @@ -636,7 +637,10 @@ export async function runWizard(initialOptions: WizardOptions): Promise<void> {
let run: Awaited<ReturnType<typeof workflow.createRun>>;
let result: WorkflowRunResult;
try {
const dirListing = await precomputeDirListing(directory);
const [dirListing, existingSentry] = await Promise.all([
precomputeDirListing(directory),
precomputeSentryDetection(directory).catch(() => null),
]);
Comment thread
cursor[bot] marked this conversation as resolved.
Comment thread
sentry[bot] marked this conversation as resolved.
const fileCache = await preReadCommonFiles(directory, dirListing);
spin.message("Connecting to wizard...");
run = await workflow.createRun();
Expand All @@ -650,6 +654,7 @@ export async function runWizard(initialOptions: WizardOptions): Promise<void> {
features,
dirListing,
fileCache,
existingSentry: existingSentry?.data,
},
tracingOptions,
}),
Expand Down
4 changes: 4 additions & 0 deletions test/lib/init/wizard-runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ beforeEach(() => {
"precomputeDirListing"
).mockResolvedValue([]);
spyOn(ops, "preReadCommonFiles").mockResolvedValue({});
spyOn(ops, "precomputeSentryDetection").mockResolvedValue({
ok: true,
data: { status: "none", signals: [] },
});
handleInteractiveSpy = spyOn(inter, "handleInteractive").mockResolvedValue({
action: "continue",
});
Expand Down
Loading