Closed leanderiversen closed 4 months ago
It is executing the function, these functions are supposed to throw those exceptions. But it should be handled by NextServer
itself.
I've tried to reproduce with something like that with next@14.1.2
and sst@2.40.6
and it works just fine.
Could you provide a minimum reproduction ?
import React from 'react';
import Image from 'next/image';
import { notFound, redirect } from 'next/navigation';
export const dynamic = "force-dynamic"
const Product = async ({ params: { id } }: { params: { id: string } }) => {
if(id=== "not-found") {
notFound()
}
if(id === "redirect") {
redirect("/product/1")
}
return (
<div>
THE COMPONENT
</div>
);
};
Hi,
Please find the minimum reproduction here: https://github.com/leanderiversen/open-next-379
It looks like there could be an issue with output: standalone
, rather than OpenNext, as it looks like it fails to fetch the CSS and JS required.
Happy to report this to Next directly if that is the case.
Thank you!
This does not reproduce the issue at all, i added sst and deployed and both notFound
and redirect
works.
For your information, with standalone output you have to manually add the css and js
Hi,
I am very sorry about this. Following your feedback, I have managed to find the root cause, which was an unexpected error in the fetch function used in generateStaticParams
, when there were no data to fetch. The fetch function returns an empty array when there is no content during build, so I suspect that something was going wrong when trying to fetch the data on demand when visiting the /blogs/[slug]
pages.
Sorry for the inconvenience this has caused.
Hi,
We have just discovered an issue where we can see
Runtime.UnhandledPromiseRejection
in the logs when using thenotFound
orredirect
functions fromnext/navigation
. The error messages areError: NEXT_NOT_FOUND
andError: NEXT_REDIRECT
, with the page itself displayingInternal Server Error
, rather than executing the function.This is a replica of the code, which lives in this file path:
/src/app/blogs/[slug]/page.tsx
.When running this locally, it works as expected, with either a 404 page or redirect. We are using
Next 14.1.2
,SST 2.40.6
and OpenNext2.3.7
.If there is more information I can provide, please just ask.
Thank you.