What is next-action header and why is missing
Unanswered
AM posted this in #help-forum
AMOP
Hello on one of my server actions i get this error:
Happens only on prod tho but is very important server action for authenticating users and wondering what might be the issue and how to resolve it. I have it locally few times but after deleting
Error: Failed to find Server Action "null". This request might be from an older or newer deployment. Original error: Invariant: Missing 'next-action' header.
at ry (/var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:1666)
at /var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:15:7035
at AsyncLocalStorage.run (node:async_hooks:338:14)
at rm (/var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:15:6350)
at rq (/var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:18:1255)
at /var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:18:3935
at AsyncLocalStorage.run (node:async_hooks:338:14)
at Object.wrap (/var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:13:16239)
at /var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:18:3825
at AsyncLocalStorage.run (node:async_hooks:338:14)Happens only on prod tho but is very important server action for authenticating users and wondering what might be the issue and how to resolve it. I have it locally few times but after deleting
.next folder everything start working but i don't have such access to prod env any suggestions15 Replies
AMOP
In general i believe it fails in this piece of code:
function useCompleteOnboarding({
userAddress,
currentUser,
balance,
}: {
userAddress: Address;
currentUser: Optional<WarpcastProfileType>;
balance: Optional<string>;
}) {
const postHog = usePostHog();
const router = useRouter();
const pathname = usePathname();
const completedOnboardingFlow = async ({
postHogEvent,
}: {
postHogEvent:
| 'onboarding_flow_success'
| 'onboarding_flow_skip_deposit_success';
}) => {
if (!currentUser) {
return;
}
try {
const answeredQuestions = await getAnsweredQuestionsAction();
postHog.capture(postHogEvent, {
fid: currentUser.fid,
username: currentUser.username,
user_address: userAddress,
balance,
$set_once: { fid: currentUser.fid },
});
await Promise.all([
setOnboardingStatusCookieAction({
onboarding_status: ONBOARDING_STATUS.COMPLETED,
}),
updateProfileAction({
fid: currentUser.fid,
onboarding_status: ONBOARDING_STATUS.COMPLETED,
...answeredQuestions,
}),
]);
router.push(`${pathname}?step=5`);
} catch (err) {
console.log('Err', err);
}
};
return { completedOnboardingFlow };
}we have 3 operations:
1. write to posthog
2. write to cookie
3. write to supabase
based on the error that is happening:
I assume it might be the cookie
1. write to posthog
2. write to cookie
3. write to supabase
based on the error that is happening:
at AsyncLocalStorage.run (node:async_hooks:338:14)I assume it might be the cookie
writting to cookie looks like this in another server action:
export async function setOnboardingStatusCookieAction({
onboarding_status,
}: {
onboarding_status: string;
}) {
cookies().set(COOKIES_KEYS.ONBOARDING_STATUS, onboarding_status);
}and writting to supabaes looks liek this:
export async function updateProfileAction({
fid,
question1,
question2,
question3,
onboarding_status,
}: UpdateSupabaseProfileParams) {
const { data, error } = await supabaseClient
.from('users')
.update({
question1,
question2,
question3,
onboarding_status: onboarding_status,
})
.eq('fid', fid);
}now few things not all of the users but most have this issue
happens only on prod
this version is being live for over a week so i was thinking if is cache or something will get clear
If i run yarn yarn build && yarn start and simulate the flow i manage to get this one:
apart from that i can observe that cookie has been updated actually:
but in database is not:
I've added some logs:
function useCompleteOnboarding({
userAddress,
currentUser,
balance,
}: {
userAddress: Address;
currentUser: Optional<WarpcastProfileType>;
balance: Optional<string>;
}) {
const postHog = usePostHog();
const router = useRouter();
const pathname = usePathname();
const completedOnboardingFlow = async ({
postHogEvent,
}: {
postHogEvent:
| 'onboarding_flow_success'
| 'onboarding_flow_skip_deposit_success';
}) => {
if (!currentUser) {
return;
}
try {
const answeredQuestions = await getAnsweredQuestionsAction();
console.log(1);
postHog.capture(postHogEvent, {
fid: currentUser.fid,
username: currentUser.username,
user_address: userAddress,
balance,
$set_once: { fid: currentUser.fid },
});
console.log(2);
await setOnboardingStatusCookieAction({
onboarding_status: ONBOARDING_STATUS.COMPLETED,
}),
console.log(3);
await updateProfileAction({
fid: currentUser.fid,
onboarding_status: ONBOARDING_STATUS.COMPLETED,
...answeredQuestions,
}),
console.log(4);
router.push(`${pathname}?step=5`);
} catch (err) {
console.log('Err', err);
}
};
return { completedOnboardingFlow };
}and here
export async function updateProfileAction({
fid,
question1,
question2,
question3,
onboarding_status,
}: UpdateSupabaseProfileParams) {
const { data, error } = await supabaseClient
.from('users')
.update({
question1,
question2,
question3,
onboarding_status: onboarding_status,
})
.eq('fid', fid);
if (error) {
console.log('db error', error);
}
}i can see successfully 1 2 3 4
and db error is not displayed
Ichneumonid wasp
I'm experiencing this error on a route handler, weirdly enough. Deployed to Vercel and also only occurring when using a custom domain (not .vercel.app). Not happening locally.