Has anyone encountered DYNAMIC_SERVER_USAGE due to using unstable_caching in Next.js?

26 views Asked by At

There are no errors in dev environment, and when built, there is no errors too. I only encountered this issue when running my build.


supabaseClient
'use server'
import { unstable_cache } from 'next/cache';
import { cookies } from 'next/headers'
import { createServerComponentClient } from '@supabase/auth-helpers-nextjs';


export const getTrips=  unstable_cache( async ()=>{
                const cookieStore = await cookies()
                const supabase = createServerComponentClient({ cookies:()=>cookieStore });
                
                        return await supabase.from("trips").select()


                }, ['trips'],
                { tags:['trips']}
                
        )
Dashboard: 
export default  async function Page() {
  //console.error('user')


   
   const  data=  await getTrips()///error causes DYNAMIC_SERVER_USAGE
  
  return (
    <main className="    w-screen   h-screen   bg-blue-500 ">
      <div type="main" className="  z-10 top-0   font-mono flex  flex-wrap overflow-y-auto">

             {
        data? 
         data.map((info) => <Card key={info.id} data={info}></Card> )
            :(<></>)
            
            
        
    }

      </div>


    </main>
  )
}


I have identified the problem and would like to know why it occurs. My error comes from const data=await getTrips()

  )
}

export default  async function Page() {
  const cookieStore = await cookies()
  const supabase = createServerComponentClient({ cookies:()=>cookieStore });
                
   const{data, error}=  await supabase.from("trips").select()


   

  
  return (
    <main className="    w-screen   h-screen   bg-blue-500 ">
      <div type="main" className="  z-10 top-0   font-mono flex  flex-wrap overflow-y-auto">

             {
        data? 
         data.map((info) => <Card key={info.id} data={info}></Card> )
            :(<></>)
            
            
        
    }

      </div>


    </main>
  )
}

When I moved all the content from getTrips() into page(), everything works perfectly. Does anybody have an explanation for why this error occurs?

0

There are 0 answers