I have written backend html code so that I can query a database through a python script and load it into a power bi. It worked great for a while but now it seems that the database has become too big. I get a 504 timeout error, but it’s not because anything is wrong, but because the database is taking longer than 14 seconds to pull. Is there any way I can override the 14 second timeout?
Cody, you cannot. Just a question: are you pulling data INTO a Wix Page or into an html-page outside Wix using the Wix DB? Bit confused what you meant by “backend html code”, because in Wix, there is no such thing.
But maybe there’s a workaround, if you can tell me what you are doing.
I send an html request to the website.
import { ok, notFound, serverError, forbidden } from 'wix-http-functions';
import wixData from 'wix-data';
import { getSecret } from 'wix-secrets-backend';
export async function use_get_query(request) {
const mySecret = await(getSecret("data_secret").then(function (secret) {return(secret)}));
if (request.query.secret === mySecret) {
console.log(request.query)
console.log("Working")
let options = {
"headers": {
"Content-Type": "application/json"
}
};
let more_options = {
"suppressAuth": true
};
let allItems = [];
let results = await wixData.query(request.query.collection)
.limit(100)
.find(more_options)
.catch(err => {return err})
allItems.push(results.items);
while(results.hasNext()) {
results = await results.next();
//allItems = allItems.concat(results.items);
allItems.push(results.items);
}
console.log(allItems.length)
allItems = [].concat.apply([],allItems)
options.body = {
"items": allItems
}
return ok(options)
}
return (forbidden("Access Denied"));
}
I responded below. I unpack the json response full of the data by using a python script.
OK got it. And "use_get_query ( request ) " you are calling from the frontend, right?
If so, yes, you can run into the 14 secs timeout (frontend to backend call). Only way out: move all backend code to the frontend (=page). If done (so not calling a backend function) there, it will run “forever” (not quite, there’s another timeout, the db-token), but let’s not get ahead of ourselves.
EDIT: did you know that backend processes, called from frontend, will keep running, although frontend times out? I use that. Error in frontend, don’t care, backend keeps running.