ConvertX icon indicating copy to clipboard operation
ConvertX copied to clipboard

Going back to the upload page after converting reuses the finished job: results show the old file and stay in progress

Open Karanvir1729 opened this issue 3 weeks ago • 0 comments

Describe the bug

After a conversion, pressing the browser's Back button shows the upload page again without asking the server for it. Chromium restores it from the back/forward cache, or from its HTTP cache. That page still belongs to the job that was just converted (the jobId cookie is unchanged), so the next upload and conversion go into the same job.

The results page then shows the earlier output as finished and does not list the new one. After a reload it lists both, but the progress bar does not fill and Delete and Tar stay disabled.

To Reproduce

  1. Open ConvertX, add first.png, pick jpg (imagemagick), click Convert. The results page shows first.jpg.
  2. Press the browser's Back button.
  3. Convert again: pick webp for the file that is still listed (or, if the list is empty, add second.png and pick webp), then click Convert.
  4. The results page has the same job id as in step 1. It shows only first.jpg, and the new output does not appear.
  5. Reload the page. Both outputs are listed, but the progress bar is not filled, and Delete and Tar stay disabled.

If you go back with the header's ConvertX link instead of the Back button, a new job starts and everything works.

What was measured

Setup: a local copy of main at 57a884d (v0.20.0) with HTTP_ALLOWED=true and ALLOW_UNAUTHENTICATED=true. A stand-in magick copied the input to the output so conversions could finish. The steps were driven with Playwright in Chromium 153, and the outcome was read from the jobs and file_names tables.

  • Back, with the back/forward cache enabled: the conversion went into the finished job in 5 of 5 runs. Each time the page came back with the old file still listed. 4 s after the second submit, the results page showed only the old output. The job had 2 file rows but num_files was 1, and after a reload Delete was disabled.
  • Back, without the back/forward cache (the page came from the HTTP cache and no request reached the server): the same result in 5 of 5 runs.
  • Control, using the header link instead of Back: 0 of 5 runs were affected. Each run got a new job, and its results were correct.

Cause

  • GET / creates the job and sets the jobId cookie (src/pages/root.tsx:111-130) but sends no Cache-Control. On Back, the browser can show a stored copy, so no new job is created.
  • POST /convert accepts a job that was already converted. It overwrites num_files with the new file count (src/pages/convert.tsx:80), while handleConvert appends rows (src/converters/main.ts:175).
  • The results page treats a job as finished only when its row count equals num_files (src/pages/results.tsx:31-54, public/results.js:8). Right after the second submit, the old row alone matches num_files, so polling stops immediately. Once the new row is added, the two counts never match again.

Checklist:

  • [x] I am accessing ConvertX over HTTPS or have HTTP_ALLOWED=true (the reproduction above ran with HTTP_ALLOWED=true)

AI assistance: Claude (Claude Code) investigated this, reproduced it with the measurements above, wrote a fix and a test, and drafted this report. I have not reproduced it by hand or reviewed the fix myself yet.

Karanvir1729 avatar Nov 07 '26 03:11 Karanvir1729