Next.js fails on build
Unanswered
American black bear posted this in #help-forum
American black bearOP
I have this simple code:
and it fails on build:
import {Suspense} from 'react';
import {getTicket} from '@/data/graphql/use-cases/get-tickets';
export default async function Page() {
const ticket = await getTicket({ticketId: '1'});
// eslint-disable-next-line no-console
console.log('ticket', ticket);
return (
<Suspense>
<div></div>
</Suspense>
);
}
and it fails on build:
✓ Collecting page data
Failed to build /(protected)/logi/page: /logi (attempt 1 of 3) because it took more than 60 seconds. Retrying again shortly.
13 Replies
American black bearOP
I am using next.js 15
@American black bear I have this simple code:
import {Suspense} from 'react';
import {getTicket} from '@/data/graphql/use-cases/get-tickets';
export default async function Page() {
const ticket = await getTicket({ticketId: '1'});
// eslint-disable-next-line no-console
console.log('ticket', ticket);
return (
<Suspense>
<div></div>
</Suspense>
);
}
and it fails on build: ` ✓ Collecting page data
Failed to build /(protected)/logi/page: /logi (attempt 1 of 3) because it took more than 60 seconds. Retrying again shortly.`
it looks like your function for the getTicket does not respond. So it may be possible, that your graphql server is not responding or you didnt add you env variables to your hoster or your graphql is not responding...
@B33fb0n3 it looks like your function for the getTicket does not respond. So it may be possible, that your graphql server is not responding or you didnt add you env variables to your hoster or your graphql is not responding...
American black bearOP
I wrote a simple api call using apollo and the build passed... don't know what's wrong with my apollo client tbh
every time that I create a new page with that ismple content, the build fails
// fails
export async function getTickets(variables?: GetTicketsDto) {
const apolloClient = initializeApollo();
const {data} = await apolloClient.query<TicketsQuery, TicketsQueryVariables>({
query: GET_TICKETS,
variables: {
dto: variables,
},
});
return data;
}
// it works
export async function getTicket(variables?: GetTicketDetailsDto) {
const client = new ApolloClient({
ssrMode: true,
link: createHttpLink({
uri: 'http://localhost:3010',
credentials: 'same-origin',
}),
cache: new InMemoryCache(),
});
const {data} = await client.query<GetTicketDetailsQuery, GetTicketDetailsQueryVariables>({
query: GET_TICKET,
variables: {
dto: variables,
},
});
return data;
}
@American black bear yea that might be the reason. Check the client and also like I already mentioned your graphql server
@B33fb0n3 <@713793871401844816> yea that might be the reason. Check the client and also like I already mentioned your graphql server
American black bearOP
it doesn’t make any sense
why everything is working?
and when I create a new page the error happens?
if I delete the page then the build succeeds
otherwise it fails
@B33fb0n3 <@713793871401844816> yea that might be the reason. Check the client and also like I already mentioned your graphql server
American black bearOP
it looks like a bug
I just created a details page to receive params and it works