Next.js Discord

Discord Forum

/app/[route] values populated by edge config not updating in prod deployments; fine locally

Unanswered
Rohu posted this in #help-forum
Open in Discord
RohuOP
Hello!

I am dynamically creating URLs based on this vercel KV (I know the token is posted; nothing sensitive included):
https://edge-config.vercel.com/ecfg_b53rxqfdo6nlfnvkaezshynzrbvf?token=ccbee030-10b3-4cf7-acc7-158e5b36417f
{
    "items": {
        "companies": {
            "test": {
                "code": "123",
                "name": "Bar"
            },
            "test2": {
                "code": "abc",
                "name": "Foo"
            }
        },
    // snip
}


Essentially, I populate pages at hire.timfeeley.com/[slug]/[code] based on the companies object, using the key for [slug] and companies.code for [code].

Here's the page:
https://github.com/timfee/hire/blob/main/app/%5Bslug%5D/%5Bcode%5D/page.tsx#L181


export default async function Page({
  params,
}: {
  params: { slug: string; code: string }
}) {
  if (!params || !params.code || !params.slug) {
    return notFound()
  }
  const { code, slug } = params

  const company = await getCompanyData(slug, code)
  if (!company) {
    return notFound()
  }
  // return page
  // snip
}        
export async function generateStaticParams() {
  const companies = await getCompanies()
  if (!companies) return []

  const paths = []
  for (const company in companies) {
    paths.push({
      slug: company,
      code: companies[company].code,
    })
  }
  return paths
}


I'm getting data from:
https://github.com/timfee/hire/blob/main/lib/queries.ts
export const getCompanyData = async (slug: string, code: string) => {
  const allCompanies = await getCompanies()
  if (allCompanies && allCompanies[slug] && allCompanies[slug].code === code) {
    return allCompanies[slug]
  }
}

export async function getCompanies() {
  return await get<{ [key: string]: CompanyType }>("companies")
}

1 Reply

RohuOP
Prior to today, anytime I'd update my companies object, I'd be able to access the newly generated url (e.g. hire.timfeeley.com/test/123) right away.

Today, it perpetually 404s; even doing a re-deploy generates an ISR based on stale data -- e.g. not all of entries appear to get parsed.

It works totally fine locally using next dev but it's the production instance that seems to be "out of sync" and for the life of me I can't figure out what's going on.

I went so far as to re-generate a brand new kv store, but even that only gets partially processed at build time.

Is there something glaringly wrong in my approach or is there some outage / issue with the KV service?

Thanks!