Hello all!
I am running into an issue that to the best of my knowledge was not present until recently. On certain pages, I have backend functions that are called during onReady. What I am noticing is that the backend function is running twice when I refresh the page. The client side code is only running once (tested through a series of console.logs and the Site Monitor), but the backend function will still run twice. On some of these, it’s adding duplicate information to a database which is highly undesirable.
I have checked for other callers, misplaced code, etc, and I cannot determine why this could be happening. Here is an example of where I have seen this:
Page: Home
URL: prycd.com
Method: getTotalExportCount
Backend File: stats.jsw
Frontend Snippet
import {getTotalExportCount, getTotalSearches, getTotalUploads} from 'backend/stats.jsw'
...
console.log("this prints once")
let [total_searches, total_export_count, total_upload_count] = await Promise.all([getTotalSearches(),
getTotalExportCount(), getTotalUploads()])
console.log("this prints once")
Backend Snippet
export async function getTotalExportCount(){
console.log("this prints twice")
No other function calls getTotalExportCount from anywhere on the site.
Any help would be massively appreciated!