From e0f7b4f2109420f6c430bee924d427ec1d55d448 Mon Sep 17 00:00:00 2001 From: Jared Schoeny Date: Sat, 13 Dec 2025 21:24:37 -1000 Subject: [PATCH] Add mitigations to help track upload network error bug --- src/app/submit/actions.ts | 18 ++++++++++++++++++ src/components/Hack/HackSubmitForm.tsx | 11 ++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/app/submit/actions.ts b/src/app/submit/actions.ts index 19ad12b..6f28f4a 100644 --- a/src/app/submit/actions.ts +++ b/src/app/submit/actions.ts @@ -110,6 +110,24 @@ export async function prepareSubmission(formData: FormData) { } } + if (process.env.DISCORD_WEBHOOK_ADMIN_URL) { + const { data: profile } = await supabase.from('profiles').select('*').eq('id', user.id).single(); + const displayName = profile?.username ? `@${profile.username}` : user.id; + + const embed: APIEmbed = { + title: `Hack submission: ${title}`, + description: `A new hack by **${displayName}** is being prepared for submission.`, + color: 0x40f56a, + url: `${process.env.NEXT_PUBLIC_SITE_URL}/hack/${slug}`, + footer: { + text: `This message brought to you by Hackdex` + } + } + await sendDiscordMessageEmbed(process.env.DISCORD_WEBHOOK_ADMIN_URL, [ + embed, + ]); + } + return { ok: true, slug } as const; } diff --git a/src/components/Hack/HackSubmitForm.tsx b/src/components/Hack/HackSubmitForm.tsx index aa7307a..762a34a 100644 --- a/src/components/Hack/HackSubmitForm.tsx +++ b/src/components/Hack/HackSubmitForm.tsx @@ -436,9 +436,13 @@ export default function HackSubmitForm({ fd.set('permission_from', permissionFrom); } + console.log('[HackSubmitForm] Preparing submission...'); + const prepared = await prepareSubmission(fd); if (!prepared.ok) throw new Error(prepared.error || 'Failed to prepare'); + console.log('[HackSubmitForm] Uploading covers...'); + const uploadedCoverUrls = await uploadCovers(prepared.slug); if (isArchive) { @@ -453,10 +457,12 @@ export default function HackSubmitForm({ } catch {} window.location.href = `/hack/${prepared.slug}`; } else { + console.log('[HackSubmitForm] Getting patch upload URL...'); const presigned = await presignPatchAndSaveCovers({ slug: prepared.slug, version, coverUrls: uploadedCoverUrls }); if (!presigned.ok) throw new Error(presigned.error || 'Failed to presign'); if (patchFile) { + console.log('[HackSubmitForm] Uploading patch...'); await fetch(presigned.presignedUrl, { method: 'PUT', body: patchFile, headers: { 'Content-Type': 'application/octet-stream' } }); const finalized = await confirmPatchUpload({ slug: prepared.slug, objectKey: presigned.objectKey!, version, firstUpload: true }); if (!finalized.ok) throw new Error(finalized.error || 'Failed to finalize'); @@ -468,6 +474,7 @@ export default function HackSubmitForm({ } catch {} window.location.href = finalized.redirectTo!; } else { + console.log('[HackSubmitForm] No patch file, redirecting to hack page...'); try { if (draftKey) { localStorage.removeItem(draftKey); @@ -477,8 +484,10 @@ export default function HackSubmitForm({ window.location.href = `/hack/${prepared.slug}`; } } + console.log('[HackSubmitForm] Submission successful'); } catch (e: any) { - alert(e.message || 'Submission failed'); + console.log('[HackSubmitForm] Submission failed', e); + alert(e.message ? `There was an error during submission:\n\n===\n${e.message}\n===\n\nYour hack might have only been partially submitted. Try going to your dashboard and see if your hack is listed there. If not, please contact support.` : 'Submission failed'); } finally { setSubmitting(false); }