slymnoyann/hey-1 · warning · Error
Please wait for attachments to finish uploading.
Error message
Please wait for attachments to finish uploading.
What it means
Thrown by assertUploadedAttachment in usePostMetadata.tsx when an attachment lacks a uri or mimeType. Attachments only get these fields after uploadToIPFS completes, so the error means the caller tried to build post metadata while one or more attachments were still uploading (or failed to upload).
Source
Thrown at src/hooks/usePostMetadata.tsx:28
import { usePostLicenseStore } from "@/store/non-persisted/post/usePostLicenseStore";
import { usePostVideoStore } from "@/store/non-persisted/post/usePostVideoStore";
import { usePostAudioStore } from "../store/non-persisted/post/usePostAudioStore";
interface UsePostMetadataProps {
baseMetadata: any;
}
const usePostMetadata = () => {
const { videoDurationInSeconds, videoThumbnail } = usePostVideoStore();
const { audioPost } = usePostAudioStore();
const { license } = usePostLicenseStore();
const { attachments } = usePostAttachmentStore();
const assertUploadedAttachment = (
attachment: (typeof attachments)[number] | undefined
) => {
if (!attachment?.uri || !attachment.mimeType) {
throw new Error("Please wait for attachments to finish uploading.");
}
return { ...attachment, uri: attachment.uri };
};
const formatAttachments = () =>
attachments.slice(1).map((attachment) => ({
item: assertUploadedAttachment(attachment).uri,
type: attachment.mimeType
}));
const getVideoDuration = () => {
const duration = Number.parseFloat(videoDurationInSeconds);
if (!videoThumbnail.url || !Number.isFinite(duration) || duration <= 0) {
throw new Error("Add a valid video thumbnail before posting.");
}
return duration;View on GitHub (pinned to 88c8f9d553)
Solutions
- Disable the post button while any attachment has no uri (track uploading state in the store)
- Check assertUploadedAttachment-equivalent conditions in onPublish before proceeding and show 'uploading' feedback instead of throwing
- Ensure failed uploads mark the attachment as errored and are removed/retried so they can't block forever
- Await the upload promise (or an uploads-complete flag) before invoking metadata generation
Example fix
// before
const onPublish = async () => {
const metadata = getMetadata({ baseMetadata }); // may throw mid-upload
};
// after
const isUploading = attachments.some((a) => !a.uri || !a.mimeType);
const onPublish = async () => {
if (isUploading) {
toast.error("Please wait for attachments to finish uploading.");
return;
}
const metadata = getMetadata({ baseMetadata });
}; Defensive patterns
Strategy: validation
Validate before calling
const isAttachmentReady = (a: { uri?: string; mimeType?: string }) =>
Boolean(a.uri && a.mimeType);
const allReady = attachments.every(isAttachmentReady);
if (!allReady) {
toast.error("Attachments are still uploading");
return;
} Type guard
type UploadedAttachment = { uri: string; mimeType: string };
const isUploadedAttachment = (
a: { uri?: string; mimeType?: string } | undefined
): a is UploadedAttachment => Boolean(a && a.uri && a.mimeType); Try / catch
try {
const primary = uploadedPrimaryAttachment();
} catch (e) {
if (e instanceof Error && e.message.includes("wait for attachments")) {
// wait or block publish; do not retry immediately
}
} Prevention
- Disable the publish action while any attachment lacks uri/mimeType
- Mark failed uploads as errored and force remove/retry so they never block publish
- Await upload completion promises before enabling metadata generation
When it happens
Trigger: Calling formatAttachments or reading uploadedPrimaryAttachment while an upload is in flight (uri still empty), when an upload failed and left the attachment in a partial state, or when publishing with zero attachments where the primary attachment is undefined.
Common situations: User hits 'Post' before the upload spinner finishes; upload promise rejected silently so uri never got set; race between the attachment store updating and the publish handler reading it; large media on slow connections exceeding user patience.
Related errors
AI-assisted analysis of slymnoyann/hey-1@88c8f9d553 (2026-08-28).
Data as JSON: /api/errors/104b4313ca3fe206.
Report an issue: GitHub.