Going back to the upload page after converting reuses the finished job: results show the old file and stay in progress
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
- Open ConvertX, add
first.png, pickjpg(imagemagick), click Convert. The results page showsfirst.jpg. - Press the browser's Back button.
- Convert again: pick
webpfor the file that is still listed (or, if the list is empty, addsecond.pngand pickwebp), then click Convert. - The results page has the same job id as in step 1. It shows only
first.jpg, and the new output does not appear. - 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_fileswas 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 thejobIdcookie (src/pages/root.tsx:111-130) but sends noCache-Control. On Back, the browser can show a stored copy, so no new job is created.POST /convertaccepts a job that was already converted. It overwritesnum_fileswith the new file count (src/pages/convert.tsx:80), whilehandleConvertappends 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 matchesnum_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 withHTTP_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.