#Promise that postgres library returns does not make loading.jsx work when opening the page.

3 messages · Page 1 of 1 (latest)

grizzled pagoda
#
import Comp from './ui'
import db from '@/db/db' // uses this library https://github.com/porsager/postgres

export const revalidate = 0

/*
 * This getStuff makes loading.jsx appear
 */
async function getStuff() {
  try {
    await new Promise((resolve) => setTimeout(resolve, 2000))
    return []
  } catch (err) {
    console.log(err)
    throw new Error('err')
  }
}


/*
 * This getStuff does not make loading.jsx appear when opening the page. Why?
 * Both getStuff funtions return a promise. What is the difference?
 */
async function getStuff() {
  try {
    const stuff = await db`
        select * from myStuffTable
    `
    return stuff
  } catch (err) {
    console.log(err)
    throw new Error('err')
  }
}

export default async function Stuff() {
  const stuff = await getStuff()
  return <Comp stuff={stuff} />
}
grizzled pagoda
#

Has anyone had a similar case with this?

wide gazelle
#

Yes, I also have this problem, but only in Safari. It works in every other browser. Had this issue in 2 Projects so far.