Unhandled Runtime Error TypeError: message is null #1103
Labels
bug
Something isn't working
help-needed
The maintainer needs help due to time constraint/missing knowledge
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);
`
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",
Feedback
Documentation refers to searching through online documentation, code comments and issue history. The example project refers to next-auth-example.
The text was updated successfully, but these errors were encountered: