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

Unhandled Runtime Error TypeError: message is null #1103

Closed
4 tasks
HeikoMueller opened this issue Jan 13, 2021 · 1 comment
Closed
4 tasks

Unhandled Runtime Error TypeError: message is null #1103

HeikoMueller opened this issue Jan 13, 2021 · 1 comment
Labels
bug Something isn't working hacktoberfest-help-needed The maintainer needs help due to time constraint/missing knowledge

Comments

@HeikoMueller
Copy link

HeikoMueller commented Jan 13, 2021

Describe the bug
When using Nextauth with Credentials Provider and JWT in dev mode and in conjunction with cypress, the following error message gets thrown:

Unhandled Runtime Error

TypeError: message is null
Call Stack
_ref<
node_modules/next-auth/dist/client/index.js (47:0)
asyncGeneratorStep
node_modules/next-auth/dist/client/index.js (22:82)
_next
node_modules/next-auth/dist/client/index.js (24:192)
_asyncToGenerator/</<
node_modules/next-auth/dist/client/index.js (24:362)
_asyncToGenerator/<
node_modules/next-auth/dist/client/index.js (24:88)

node_modules/next-auth/dist/client/index.js (60:0)

The corresponding part of the code is:

`
if (typeof window !== 'undefined') {
if (__NEXTAUTH._eventListenersAdded === false) {
__NEXTAUTH._eventListenersAdded = true;
window.addEventListener('storage', function () {
var _ref = _asyncToGenerator(function* (event) {
if (event.key === 'nextauth.message') {
var message = JSON.parse(event.newValue);

      if (message.event && message.event === 'session' && message.data) {
        if (__NEXTAUTH._clientId === message.clientId) {
          return;
        }

        yield __NEXTAUTH._getSession({
          event: 'storage'
        });
      }
    }
  });

`

So, the storage event is somehow called without the newValue property set.

This error is not happening after next build / next start.

Looking on the tests, I am under the impression that this only happens when I call the signIn() method with a callbackURL. However, I did not change the redirect callback handler:

redirect: async (url, baseUrl) => { return url.startsWith(baseUrl) ? Promise.resolve(url) : Promise.resolve(baseUrl) }

Steps to reproduce
Follow the description for implementing credentials provider, include cypress, run project in dev mode, open cypress and run tests

Expected behavior
Not sure if the "newValue" property has to be set manually somewhere in the session handling code ?

Additional context
node v14.15.1
npm 6.14.10
next: "10.0.1",
next-auth: "^3.1.0",

Bildschirmfoto 2021-01-13 um 16 32 18

Bildschirmfoto 2021-01-13 um 19 01 49

Feedback
Documentation refers to searching through online documentation, code comments and issue history. The example project refers to next-auth-example.

  • [ x] Found the documentation helpful
  • Found documentation but was incomplete
  • Could not find relevant documentation
  • Found the example project helpful
  • Did not find the example project helpful
@HeikoMueller HeikoMueller added the bug Something isn't working label Jan 13, 2021
@balazsorban44 balazsorban44 added the hacktoberfest-help-needed The maintainer needs help due to time constraint/missing knowledge label Jan 13, 2021
@HeikoMueller
Copy link
Author

I solved the issue with adding:

beforeEach(() => {
Cypress.Cookies.preserveOnce(
"next-auth.session-token",
"next-auth.csrf-token",
"next-auth.callback-url"
);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hacktoberfest-help-needed The maintainer needs help due to time constraint/missing knowledge
Projects
None yet
Development

No branches or pull requests

2 participants