Next.js Discord

Discord Forum

TypeError: (intermediate value).map is not a function

Answered
Birman posted this in #help-forum
Open in Discord
BirmanOP
hello,
i am trying to make a github action that builds my nextjs app before deployment. the build fails however, printing the error in the above title multiple times per page. this does not occur on a local build. i have tried switching node versions, npm ci instead of npm install, adding lint step, checking ENVs, but to no avail so far.

github action: https://github.com/sebygreen/funkysundays/blob/main/.github/workflows/deploy.yml
code: https://github.com/sebygreen/funkysundays/tree/main

a database is involved, which is at a https addess.

any help is appreciated
Answered by Birman
ok, i can now confirm that this is a pocketbase issue. i had some try catch blocks which were overriding the error returned by the database sdk, and errors now show properly. tl:dr, not a nextjs problem. thank you your help thus far though, and for the quick responses
View full answer

12 Replies

it could be complaining that one if your varables that you are .maping on isn't a list and maybe undefined for its prerendering
also your suspense here is useless as it won't wait for anything as the child isn't async and doing fetching there
BirmanOP
hello, thank you for your response.

i have narrowed down the issue to my database env not returning anything, as you have said, even though it seems ENVs are defined correctly in the repository. this would explain why it's happening on all pages where data is fetched, which is almost all of them.

cheers for noticing the redundant Suspense boundaries, i forgot to remove them.
BirmanOP
so, i have modified my github action by hardcoding the variable into a .env file, used by the build. the full build step is now as follows:
-   name: Build Next.js app
    run: |
        touch .env
        echo POCKETBASE_URL="https://pocketbase.funkysundays.com" >> .env
        npm run build

however, even with a local .env for the runner to build from, without using github variables or secrets, it still throws the same error for each page that uses fetched data from the database. i tried again on my laptop to build locally, and it goes through with success. are there any other possibilities?

i have not included variables that are used by client interactions, assuming for a build only step that they aren't needed. could this be the issue?

EDIT:
i have tried
- node v20 lts, v21.x
- defining variables globally, in job, in step, hardcoding the values, using secrets and variables
- touching a .env file with the envs
- mirroring my build attempts locally which have all succeeded
- using github cache
- looking in nextjs repository issues
- looking in forums here
- rebuilt the entire deploy workflow using different code

i'm not sure what else i can do here
Where are you hosting your db with, and could they be somehow blocking gh actions (and what db client are you using)
BirmanOP
i'm using a pocketbase instance hosted on an ubuntu vps, behind nginx reverse proxy
i will look to see if pocketbase blocks github actions somehow
@Birman i will look to see if pocketbase blocks github actions somehow
i mean, i would hope it would error instead of return nothing 😭
BirmanOP
indeed, it's very strange
BirmanOP
just tried a fresh project for testing: https://github.com/sebygreen/testing-github-actions, and it builds fine...i am very confused. errors were returned correctly when there were some, database logs show correct access, and workflow goes through with success. the database URL is the same, and works this time. i think i will ask the pocketbase community as well, as i suspect it may be something to do with it's usage
BirmanOP
ok, i can now confirm that this is a pocketbase issue. i had some try catch blocks which were overriding the error returned by the database sdk, and errors now show properly. tl:dr, not a nextjs problem. thank you your help thus far though, and for the quick responses
Answer