Load canceled due to load timeout

Hello I’ve a code that can retrieve page user input and rewrite my collection, well I’ve already test the code with small number of items in my collection (“SecretCode”) and it works pretty fine, however when I add more items in “SecretCode” collections (to 300 items) it still can read the collection but won’t do the save nor update

I’ve tried
wixData.save() , wixData.update(), wixData.bulkSave(), wixData.bulkUpdate()

but still won’t work, in my console this message appears

DevTools failed to load source map: Could not load content for https://static.parastorage.com/services/wix-thunderbolt/dist/dynamicPages.9341cb0d.chunk.min.js.map: Load canceled due to load timeout

P.S. : this code work in preview mode

import wixUser from ‘wix-users’ ;
import wixData from ‘wix-data’ ;
import wixLocation from ‘wix-location’ ;
import { memory } from ‘wix-storage’
import { session } from ‘wix-storage’
import wixWindow from ‘wix-window’ ;

let user = wixUser.currentUser ;
let userID ;

$w . onReady ( function () {
$w ( ‘#input1’ ). hide ()

// Check to make sure currentUser is logged in
if ( user.loggedIn ) {
console . log ( user );
userID = user.id ;
//obtain user data
}

wixData . query ( “MemberPoins” )
. hasAll ( “id” , userID )
. find ()
. then ( ( results ) => {
if ( results.items.length > 0 ){
memory . setItem ( “CUP” , results.items [ 0 ][ “userPoins” ]); //CUP stands for Current User Poins
memory . setItem ( “MPID” , results.items [ 0 ][ “_id” ] ) //MPID stands for Member Poins ID
} else {
wixData . save ( “MemberPoins” ,{ “id” : userID , “userPoins” : 0 }). then (()=> {
wixData . query ( “MemberPoins” )
. hasAll ( “id” , userID )
. find ()
. then ( ( results ) => {
if ( results.items.length > 0 ){
memory . setItem ( “CUP” , results.items [ 0 ][ “userPoins” ]); //CUP stands for Current User Poins
memory . setItem ( “MPID” , results.items [ 0 ][ “_id” ] ) //MPID stands for member poins ID
}

                }) 

        
        }) 
    } 

}) 

wixData . query ( “Hacktools” )
. hasAll ( “id” , userID )
. find ()
. then (( results )=>{
if ( results.items.length > 0 ){
memory . setItem ( “HTID” , results.items [ 0 ][ “_id” ]) //HTID stands for Member hacktools ID
} else {
wixData . save ( “Hacktools” ,{ “id” : userID , “hacktools” : new Array ()}). then ( ()=> {
wixData . query ( “Hacktools” )
. hasAll ( “id” , userID )
. find ()
. then ( ( results ) => {
if ( results.items.length > 0 ){
memory . setItem ( “HTID” , results.items [ 0 ][ “_id” ] ) //MPID stands for Member Poins ID
}
})
})
}
})

})

setTimeout ( function () {
$w ( “#input1” ). show ( “FadeIn” );
}, 5000 );

/**

  • Adds an event handler that runs when an input element’s value
    is changed.
  • @param {$w.Event} event
    */

export function input1_input ( event ) {
// This function was added from the Properties & Events panel. To learn more, visit Velo: Working with the Properties & Events Panel | Help Center | Wix.com
// Add your code for this event here:
if ( $w ( “#input1” ). value.length >= 16 ) {
wixData . query ( “SecretCode” )
. hasAll ( “code” , $w ( ‘#input1’ ). value )
. find ()
. then ( ( results ) => {
if (!( user.loggedIn )) {
wixLocation . to ( ‘Enghacktools’ ) //LINK
} else if ( results.items.length > 0 ) {
console . log ( “ketemu” , results )
let price = results.items [ 0 ][ “price” ];
let product = [ results.items [ 0 ][ “title” ]];
let code = results.items [ 0 ][ “code” ];
let batch = results.items [ 0 ][ “batch” ]
wixData . bulkSave ( “SecretCode” ,[{ “_id” : results.items [ 0 ][ “_id” ], “check”:“Done” , “codeinput” : code , “codeowner” : userID , “batch” : batch }]). then ( () => {
console . log ( “this is product” , product )

                    let  CUP  =  Number ( memory.getItem ( "CUP" )); 
                    let  MPID  =  memory . getItem ( "MPID" ); 
                    let  HTID  =  memory . getItem ( "HTID" ); 

                wixData . **get** ( "Hacktools" , memory . getItem ( "HTID" )). then ( ( results )=> { 
                    let  CUHT  =  results.hacktools ; 
                    console . log ( "this is CUHT"  ,  CUHT ) 
                    
                    let  currentuserpoins  =  parseInt ( CUP ) +  parseInt ( price ); 
                    wixData . save ( "MemberPoins" ,{ "_id" : MPID , "id" : userID , "userPoins" : currentuserpoins }) 
                    let  currentuserhacktools  =  CUHT . concat ( product ) 
                    console . log ( "thi is currenthacktools"  ,  currentuserhacktools ) 
                    wixData . save ( "Hacktools" ,{ "_id" : HTID , "id" : userID , "hacktools" : currentuserhacktools }) 
                        . then ( ()=>{ 
                            wixData . **get** ( "Hacktools" , HTID ) 
                                . then ( ( results ) => { 
                                console . log ( "this is results"  ,  results ) 
                                let  item  =  results.hacktools 
                                console . log ( "this is hacktools" ,  item ) 
                                
                            }) 

                        }) 
                    }) 
                    }) 
                
                

                

                session . setItem ( "price" , price ) 

                
                
        
            } **else** { 
                wixWindow . openLightbox ( "Code-Denied" );  //LINK 
                console . log ( "No Matching item" ) 
            
        } 
    }) 
}

Hey, I believe there are several optimizations to be made but nothing major. Most of the time, when code is working in preview but not in live it’s because you have authorization issues on your data (data only readable/writable by admin most of the time)

EXCEPT what the point of having a secret code database if anyone can read or write it?

Most of your code regarding the management of the SecretCode collection should be done in the back and not readable nor writable by user directly.

Thanks @plomteuxquentin , you mean that I need to code all of these in backend?