Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action Error : Output is too short #123

Closed
2 tasks done
Inalegwu opened this issue May 12, 2024 · 2 comments
Closed
2 tasks done

Action Error : Output is too short #123

Inalegwu opened this issue May 12, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Inalegwu
Copy link

Are you using the latest version of this library?

  • I verified that the issue exists in the latest next-safe-action release

Is there an existing issue for this?

  • I have searched the existing issues and found nothing that matches

Describe the bug

I found that the action errors when trying to return a redirect from an action, while trying to run an authentication flow in a project. I assume this isn't intended functionality as it isn't described anywhere in the docs.

Reproduction steps

  1. create an action that ends in a redirect
export const signup = action(signupSchema, async (input) => {
  const userExists = await db.query.users.findFirst({
    where: (user, { eq }) => eq(user.email, input.email),
  });

  if (userExists) {
    throw new Error("This email is already in use, Please try again");
  }

  const passwordHash = await argon.hash(input.password);

  const userId = generateIdFromEntropySize(10);

  await db.insert(users).values({
    id: userId,
    hashedPassword: passwordHash,
    email: input.email,
  });

  const session = await lucia.createSession(userId, {});
  const sessionCookie = lucia.createSessionCookie(session.id);

  cookies().set(
    sessionCookie.name,
    sessionCookie.value,
    sessionCookie.attributes,
  );

  return redirect("/dashboard");
});

  1. attempt running said action
  2. Result output is
Action error: output is too short

Expected behavior

On successful action run, the redirect should be run.

Reproduction example

https://github.com/Inalegwu/Pigeon

Operating System

Windows 11

Library version

6.2.0

Additional context

No response

@Inalegwu Inalegwu added the bug Something isn't working label May 12, 2024
@TheEdoRan
Copy link
Owner

I'm not sure this is related to next-safe-action. Action error: default prefix just means that an error occurred on the server.
Are you sure that the redirect function is reached while executing the action? If this is the case, please provide a link to a minimal reproduction repo/Stackblitz env, thanks!

@Inalegwu
Copy link
Author

Sorry for the false positive. It was infact an error on my part. Thanks for the advice though, it did point me in the right direction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants