Skip to content

File Upload Error 1570 - #3369

Open
SunTheDev wants to merge 16 commits into
devfrom
File-Upload_Err-1570
Open

File Upload Error 1570#3369
SunTheDev wants to merge 16 commits into
devfrom
File-Upload_Err-1570

Conversation

@SunTheDev

Copy link
Copy Markdown
Contributor

Description

When a user drag-and-drops a Word document (or any file) that is currently open in another program, the upload
silently fails with a net::ERR_FAILED network error — no feedback is shown to the user. This PR adds a clear error toast to match the existing behavior of the file picker path, which already shows a "This file is in use" message in that scenario.

Changes Made

  • packages/playground/src/stores/room/room.store.ts — In the askMessage upload catch block, detect network-level
    upload failures (TypeError: Failed to fetch / net::ERR_FAILED) and show a toast: "This file is in use. Close the
    file in the other program and try again." The toast is raised from the store itself so it fires regardless of
    whether askMessage is awaited or called fire-and-forgot (as it is in the new chat flow).

How to Test

  1. Open a .docx file in Microsoft Word (keep it open)
  2. In the chat, drag and drop that same file into the "Drop files here to attach to message" drop zone
  3. Type any message and hit Send
  4. Expected: A toast error appears saying "Uploaded file(s) currently in use by another program. Close the program and re-upload the file(s) in a new chat."
  5. Expected (before fix): The baseUpload network call fails silently with net::ERR_FAILED, no error is shown, and
    the file is not recognized by the chat
  6. Close the file in Word, repeat steps 2–3
  7. Expected: File uploads and is recognized successfully

Notes

  • The fix lives entirely in the store so it covers both the new chat flow (new-room-page.tsx calls askMessage
    fire-and-forgot with no .catch()) and the existing room flow (room-content.tsx awaits it)
  • The file picker path (Windows Explorer dialog) was already blocking locked files at the OS level before the
    browser received them — this fix brings drag-and-drop to parity with that behavior
  • Detection targets TypeError (the JS error class for network failures) and message strings Failed to fetch /
    ERR_FAILED / NetworkError to cover Chrome, Edge, and Firefox variants

@SunTheDev
SunTheDev requested a review from kzsb03 July 8, 2026 14:26
@SunTheDev SunTheDev self-assigned this Jul 8, 2026
@SunTheDev
SunTheDev requested a review from a team as a code owner July 8, 2026 14:26
@snyk-io

snyk-io Bot commented Jul 8, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

// proceeding with no attachment.
if (uploaded.length === 0) {
const uploadError = new Error(
"Uploaded file(s) currently in use by another program. Close the program and re-upload the file(s) in a new chat.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move to support internationalization


if (isNetworkOrUploadFailure || e instanceof TypeError) {
toast.error(
"Uploaded file(s) currently in use by another program. Close the program and re-upload the file(s) in a new chat.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@SunTheDev
SunTheDev requested a review from kzsb03 July 15, 2026 19:58
errMsg.includes("Failed to fetch") ||
errMsg.includes("ERR_FAILED") ||
errMsg.includes("File is in use") ||
errMsg.includes("NetworkError");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These won't actually catch the errors we're throwing

uploadInsight,
} from "@semoss/sdk/react";
import { FlexLayout, type ThemeMap } from "@semoss/shared";
import { toast } from "@semoss/ui/next";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think we should be using i18n or toast inside the store, i'd prefer to do it in the caller instead

// Tag and re-throw so awaited callers can also react if needed
const uploadError = new Error((e as Error).message);
uploadError.name = "UploadError";
(uploadError as Error & { fileNames: string[] }).fileNames =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no code reads this value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants