-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
signIn() redirects to error when used in useEffect in Firefox (v5) #9177
Comments
This error seems to be coming from a browser, not a chromium. The same error occurs in safari. May I handle this issue? please assign to me~ I'll create PR soon! |
I didn't open PR for the following reasons. In the latest version, this issue has been resolved, and the phenomenon in which the log was not visible only in chromium was that all of the log was lost during page redirection with Additionally, the openssl rand -hex 32 // auth.ts
export const authConfig = {
...
secret: "your openssl hash value"
} satisfies NextAuthConfig; As a result, |
@Celsiusss can you confirm applying secret and latest version, for example, fixes this for you in FF as well? If so I'll close this as resolved 👍 |
@Tap-Kim @ndom91 I updated next-auth to I also enabled the debug option in the auth config, but it does not yield any more logging server side. LogsNavigated to http://localhost:3000/ Navigated to http://localhost:3000/api/auth/signin?callbackUrl=http%3A%2F%2Flocalhost%3A3000%2F ClientFetchError: NetworkError when attempting to fetch resource. .Read more at [https://errors.authjs.dev#autherror](https://errors.authjs.dev/#autherror) AuthError webpack-internal:///(app-pages-browser)/./node_modules/@auth/core/errors.js:49 ClientFetchError webpack-internal:///(app-pages-browser)/./node_modules/next-auth/lib/client.js:16 fetchData webpack-internal:///(app-pages-browser)/./node_modules/next-auth/lib/client.js:50 React 2 Client webpack-internal:///(app-pages-browser)/./app/client.tsx:16 React 8 workLoop webpack-internal:///(app-pages-browser)/./node_modules/next/dist/compiled/scheduler/cjs/scheduler.development.js:261 flushWork webpack-internal:///(app-pages-browser)/./node_modules/next/dist/compiled/scheduler/cjs/scheduler.development.js:230 performWorkUntilDeadline webpack-internal:///(app-pages-browser)/./node_modules/next/dist/compiled/scheduler/cjs/scheduler.development.js:534 EventHandlerNonNull* webpack-internal:///(app-pages-browser)/./node_modules/next/dist/compiled/scheduler/cjs/scheduler.development.js:569 webpack-internal:///(app-pages-browser)/./node_modules/next/dist/compiled/scheduler/cjs/scheduler.development.js:630 NextJS 4 webpack-internal:///(app-pages-browser)/./node_modules/next/dist/compiled/scheduler/index.js:4 NextJS 4 React 2 NextJS 4 webpack-internal:///(app-pages-browser)/./node_modules/next/dist/compiled/react-dom/index.js:32 NextJS 4 webpack-internal:///(app-pages-browser)/./node_modules/next/dist/compiled/react-dom/client.js:3 NextJS 4 webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/app-index.js:16 NextJS 4 webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/app-next-dev.js:9 appBootstrap webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/app-bootstrap.js:57 loadScriptsInSequence webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/app-bootstrap.js:23 appBootstrap webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/app-bootstrap.js:56 webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/app-next-dev.js:8 NextJS 7 [app-index.js:34:22](webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/app-index.js) Navigated to http://localhost:3000/api/auth/error It works in about 1 out of 20 times, surprisingly. I updated the reproduction project to reflect the next-auth update and included the .env file. |
Interesting.. Looks like the same issue I have mentioned here (ndom91/briefkasten#40) |
I was able to resolve this issue by debouncing the call to Maybe the For instance: useEffect(() => {
const ac = new AbortController();
void signIn(provider, { signal: ac.signal });
return () => ac.abort();
}, []); We ended up with this solution: const signingIn = useRef(false);
useEffect(() => {
if (signinIn.current) return;
signingIn.current = true;
void signIn(provider);
}, []); |
Environment
System:
OS: Linux 6.6 Arch Linux
CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
Memory: 10.37 GB / 31.26 GB
Container: Yes
Shell: 5.9 - /usr/bin/zsh
Binaries:
Node: 21.2.0 - /usr/bin/node
npm: 10.2.4 - /usr/bin/npm
Browsers:
Chromium: 119.0.6045.159
npmPackages:
next: 14.0.2 => 14.0.2
next-auth: ^5.0.0-beta.3 => 5.0.0-beta.3
react: ^18 => 18.2.0
Reproduction URL
https://github.com/Celsiusss/nextauth-demo/tree/signin-effect
Describe the issue
Using the
signIn()
function inside auseEffect
hook produces an error.The browser redirects to
![image](https://private-user-images.githubusercontent.com/3050747/283967522-a3020139-1e67-45bf-87de-15169da21a5d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkxODk0NzUsIm5iZiI6MTcxOTE4OTE3NSwicGF0aCI6Ii8zMDUwNzQ3LzI4Mzk2NzUyMi1hMzAyMDEzOS0xZTY3LTQ1YmYtODdkZS0xNTE2OWRhMjFhNWQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYyNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MjRUMDAzMjU1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YzMxY2M5YTFhYTA0MWI1YzNlNzZhZDQwOWJlMTE2OGZlNTBjNDM1MmI5MDg2ZmE2OTUwMGZiNmFhMGQ5ZTkwZSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.JZicAcnOon8pJY19vlXYFcjiSjbJrx9o9Jzli9113ck)
/api/auth/error
and shows this page:Browser JS console gives one error:
call stack
The dev server does not log anything.
I could only reproduce this in Firefox.
How to reproduce
The given reproduction URL contains a minimal repo with a client component that uses the shown above code.
Expected behavior
I expected the behavior to be as in Chromium, where this works fine.
The text was updated successfully, but these errors were encountered: