Bug 41058 - Using Show Checkouts button when LoadCheckoutsTableDelay is set causes collision/error. loadIssuesTableDelayTimeoutId not assigned
Summary: Using Show Checkouts button when LoadCheckoutsTableDelay is set causes collis...
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P4 minor
Assignee: Michael Grgurev
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-10-20 18:20 UTC by Michael Grgurev
Modified: 2026-02-16 19:39 UTC (History)
7 users (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This fixes an error message when viewing the checkouts table for patrons, under either the patron's check out and details sections in the staff interface, where: - the LoadCheckoutsTableDelay system preference is set (greater than zero) - "Always show checkouts automatically" is selected Clicking "Show checkouts" when "Checkouts table will show automatically in X seconds..." is shown resulted in a pop-error message, after the table with the list of checkouts was shown: Something went wrong when loading the table 200: OK.
Version(s) released in:
Circulation function:


Attachments
[PATCH] Bug 41058: Assign timeout id when delaying issues table load (2.44 KB, patch)
2025-10-27 22:18 UTC, Michael Grgurev
Details | Diff | Splinter Review
Bug 41058: Assign timeout id when delaying issues table load (2.26 KB, patch)
2026-01-08 18:48 UTC, Lisette Scheer
Details | Diff | Splinter Review
Bug 41058: Assign timeout id when delaying issues table load (2.25 KB, patch)
2026-01-08 18:49 UTC, David Nind
Details | Diff | Splinter Review
Bug 41058: Assign timeout id when delaying issues table load (2.30 KB, patch)
2026-02-16 19:29 UTC, David Nind
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Grgurev 2025-10-20 18:20:44 UTC
Manually selecting the "Show Checkouts" button does not cancel the setTimeout associated with LoadCheckoutsTableDelay (Checkouts table will show automatically in blah seconds..)

In /intranet-tmpl/prog/js/checkouts.js, loadIssuesTableDelayTimeoutId is declared and  targeted by clearTimeout() but never applied to the setTimeout() that triggers LoadIssuesTable().

Lines 712 & 735 should be revised from

"setTimeout(function () {"

to 

"loadIssuesTableDelayTimeoutId = setTimeout(function () {"
Comment 2 Jonathan Druart 2025-10-23 11:01:00 UTC
Can you attach your patch here?
Comment 3 Michael Grgurev 2025-10-27 22:18:34 UTC Comment hidden (obsolete)
Comment 4 Lucas Gass (lukeg) 2025-11-26 20:06:55 UTC
Hey Michael,

The code changes here look good! A few thing to point out:

-The commit message should always start with "Bug XXXXX: " or else the Koha QA tools will complain, 

-Your must attach a test plan to your commit.


If you can do those 2 things we can move this along. And thanks for the patch!
Comment 5 Michael Grgurev 2025-11-26 20:19:02 UTC
Ahhh, thanks Lucas! I knew my workflow was probably out of whack somewhere. Thought I had both of those in my patch file, but I'm clearly formatting/applying something wrong.  I'll review everything and resubmit.
Comment 6 Lisette Scheer 2026-01-08 18:48:47 UTC Comment hidden (obsolete)
Comment 7 David Nind 2026-01-08 18:49:20 UTC
Created attachment 191034 [details] [review]
Bug 41058: Assign timeout id when delaying issues table load

When AlwaysLoadCheckoutsTable is enabled and a delay is configured,
we were calling setTimeout without capturing the returned id, despite a
`loadIssuesTableDelayTimeoutId` variable already being declared and targetted
by clearTimeout. This prevented the "Load now" button from properly clearing
the pending timeout.

Test plan:
1. Configure a delay (LoadCheckoutsTableDelay > 0) so checkouts table
   loads after N seconds.
2. Go to a patron’s checkouts page.
3. Before the delay completes, click "Load now".
   - Without this patch: an alert window will display a "Something went wrong
	 when loading the table" error once the timeout triggers.
   - With this patch: the pending timeout is cleared; the table loads
     immediately only once.
4. Reload the page with the delay set; wait for the timeout to elapse
   and confirm the table loads normally.

Signed-off-by: Mike Grgurev <mike.grgurev@mainlib.org>
Comment 8 David Nind 2026-02-16 19:29:45 UTC
Created attachment 193267 [details] [review]
Bug 41058: Assign timeout id when delaying issues table load

When AlwaysLoadCheckoutsTable is enabled and a delay is configured,
we were calling setTimeout without capturing the returned id, despite a
`loadIssuesTableDelayTimeoutId` variable already being declared and targetted
by clearTimeout. This prevented the "Load now" button from properly clearing
the pending timeout.

Test plan:
1. Configure a delay (LoadCheckoutsTableDelay > 0) so checkouts table
   loads after N seconds.
2. Go to a patron’s checkouts page.
3. Before the delay completes, click "Load now".
   - Without this patch: an alert window will display a "Something went wrong
	 when loading the table" error once the timeout triggers.
   - With this patch: the pending timeout is cleared; the table loads
     immediately only once.
4. Reload the page with the delay set; wait for the timeout to elapse
   and confirm the table loads normally.

Signed-off-by: Mike Grgurev <mike.grgurev@mainlib.org>
Signed-off-by: David Nind <david@davidnind.com>
Comment 9 David Nind 2026-02-16 19:39:35 UTC
Testing notes (using KTD):

1. Check out some items to a patron (I checked out two items to Mary Burton
   - 39999000000498, 39999000011418).

2. In either the patron's check out or details section, tick 
   "Always show checkouts automatically".

3. Set the LoadCheckoutsTableDelay system preference to 5.

4. Go back to the patron's page - either the check out or details section.

5. Next to "Show checkouts", there is "Checkouts table will show automatically
   in 5 seconds..."

6. I found reproducing step 5 and the error described in the bug a bit hit 
   in miss. This is what I did:
   . Sometimes the error message didn't show, other times it did
   . I switched between the check out and details section after selected 
     and unselecting "Always show checkouts automatically"
   . When you do get "Checkouts table will show automatically in 5 seconds..." 
     to show, click on the "Show checkouts" button
   . Don't do anything else after the check outs table is shown
   . Eventually (generally quite quickly, but sometimes a bit longer, it may
     be the time set for the LoadCheckoutsTableDelay system preference) this
     pop-up message is shown:
        Something went wrong when loading the table
        200: OK.
 
7. Apply the patch, restart_all, clear your browser cache.

8. Repeat steps 5 and 6 - no pop-up error message is shown.

7. After the patch, and when you can get "Checkouts table will show automatically in 5 seconds..." to show, the pop-up error message no longer shows.