Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

ERROR TypeError: Cannot read properties of undefined (reading 'type') #10949


User avatar
0
TimMackey created

ANZ v 8.3.1 Angular/Core 3.1

ERROR TypeError: Cannot read properties of undefined (reading 'type') occurs immediately after login as admin (http://localhost:4200/app/admin/hostDashboard). It appears to be caused by abp.notifications.getFormattedMessageFromUserNotification(userNotification); in the 'format(...)' function in UserNotificationHelper.ts. Please advise on how to fix. Thank you.

abp.js:355 DEBUG: 
abp.js:355 Connected to SignalR server!
abp.js:355 DEBUG: 
abp.js:355 Registered to the SignalR server!
core.js:4002 ERROR TypeError: Cannot read properties of undefined (reading 'type')
    at Object.abp.notifications.getFormattedMessageFromUserNotification (abp.js:311:1)
    at UserNotificationHelper.push../src/app/shared/layout/notifications/UserNotificationHelper.ts.UserNotificationHelper.format (UserNotificationHelper.ts:71:37)
    at header-notifications.component.ts:41:70
    at arrayEach (lodash.js:516:1)
    at Function.forEach (lodash.js:9342:1)
    at SafeSubscriber._next (header-notifications.component.ts:40:22)
    at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:192:1)
    at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (Subscriber.js:130:1)
    at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (Subscriber.js:76:1)
    at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:53:1)
defaultErrorLogger @ core.js:4002
push../node_modules/@angular/core/fesm5/core.js.ErrorHandler.handleError @ core.js:4050
next @ core.js:26758
schedulerFn @ core.js:23734
push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub @ Subscriber.js:192
push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next @ Subscriber.js:130
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next @ Subscriber.js:76
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:53
push../node_modules/rxjs/_esm5/internal/Subject.js.Subject.next @ Subject.js:47
push../node_modules/@angular/core/fesm5/core.js.EventEmitter.emit @ core.js:23718
(anonymous) @ core.js:26277
ZoneDelegate.invoke @ zone.js:396
Zone.run @ zone.js:153
push../node_modules/@angular/core/fesm5/core.js.NgZone.runOutsideAngular @ core.js:26214
onHandleError @ core.js:26277
ZoneDelegate.handleError @ zone.js:400
Zone.runTask @ zone.js:201
ZoneTask.invokeTask @ zone.js:513
ZoneTask.invoke @ zone.js:502
timer @ zone.js:3041
setTimeout (async)
scheduleTask @ zone.js:3062
ZoneDelegate.scheduleTask @ zone.js:417
onScheduleTask @ zone.js:304
ZoneDelegate.scheduleTask @ zone.js:410
Zone.scheduleTask @ zone.js:241
Zone.scheduleMacroTask @ zone.js:264
scheduleMacroTaskWithCurrentZone @ zone.js:1192
(anonymous) @ zone.js:3075
proto.<computed> @ zone.js:1510
hostReportError @ hostReportError.js:3
push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub @ Subscriber.js:200
push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next @ Subscriber.js:130
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next @ Subscriber.js:76
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:53
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next @ Subscriber.js:76
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:53
push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber.notifyNext @ mergeMap.js:84
push../node_modules/rxjs/_esm5/internal/InnerSubscriber.js.InnerSubscriber._next @ InnerSubscriber.js:15
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:53
push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber.notifyNext @ mergeMap.js:84
push../node_modules/rxjs/_esm5/internal/InnerSubscriber.js.InnerSubscriber._next @ InnerSubscriber.js:15
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:53
(anonymous) @ subscribeToArray.js:5
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe @ Observable.js:43
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:29
subscribeToResult @ subscribeToResult.js:13
push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._innerSub @ mergeMap.js:74
push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._tryNext @ mergeMap.js:68
push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._next @ mergeMap.js:51
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:53
reader.onload @ service-proxies.ts:26908
ZoneDelegate.invoke @ zone.js:396
onInvoke @ core.js:26255
ZoneDelegate.invoke @ zone.js:395
Zone.runGuarded @ zone.js:164
(anonymous) @ zone.js:147
load (async)
set @ zone.js:1449
(anonymous) @ service-proxies.ts:26907
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe @ Observable.js:43
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:29
push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapOperator.call @ mergeMap.js:29
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:24
subscribeToResult @ subscribeToResult.js:13
push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._innerSub @ mergeMap.js:74
push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._tryNext @ mergeMap.js:68
push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._next @ mergeMap.js:51
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:53
push../node_modules/rxjs/_esm5/internal/operators/filter.js.FilterSubscriber._next @ filter.js:38
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:53
push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber.notifyNext @ mergeMap.js:84
push../node_modules/rxjs/_esm5/internal/InnerSubscriber.js.InnerSubscriber._next @ InnerSubscriber.js:15
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:53
push../node_modules/rxjs/_esm5/internal/operators/switchMap.js.SwitchMapSubscriber.notifyNext @ switchMap.js:72
push../node_modules/rxjs/_esm5/internal/InnerSubscriber.js.InnerSubscriber._next @ InnerSubscriber.js:15
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:53
push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next @ map.js:41
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:53
reader.onload @ abpHttpInterceptor.js:158
ZoneDelegate.invoke @ zone.js:396
onInvoke @ core.js:26255
ZoneDelegate.invoke @ zone.js:395
Zone.runGuarded @ zone.js:164
(anonymous) @ zone.js:147
load (async)
set @ zone.js:1449
(anonymous) @ abpHttpInterceptor.js:157
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe @ Observable.js:43
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:29
push../node_modules/rxjs/_esm5/internal/operators/map.js.MapOperator.call @ map.js:18
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:24
subscribeToResult @ subscribeToResult.js:13
push../node_modules/rxjs/_esm5/internal/operators/switchMap.js.SwitchMapSubscriber._innerSub @ switchMap.js:51
push../node_modules/rxjs/_esm5/internal/operators/switchMap.js.SwitchMapSubscriber._next @ switchMap.js:41
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:53
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next @ Subscriber.js:76
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:53
onLoad @ http.js:1681
ZoneDelegate.invokeTask @ zone.js:431
onInvokeTask @ core.js:26246
ZoneDelegate.invokeTask @ zone.js:430
Zone.runTask @ zone.js:198
ZoneTask.invokeTask @ zone.js:513
invokeTask @ zone.js:1671
globalZoneAwareCallback @ zone.js:1708
load (async)
customScheduleGlobal @ zone.js:1810
ZoneDelegate.scheduleTask @ zone.js:417
onScheduleTask @ zone.js:304
ZoneDelegate.scheduleTask @ zone.js:410
Zone.scheduleTask @ zone.js:241
Zone.scheduleEventTask @ zone.js:267
(anonymous) @ zone.js:1984
(anonymous) @ http.js:1767
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe @ Observable.js:43
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:29
push../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchOperator.call @ catchError.js:18
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:24
push../node_modules/rxjs/_esm5/internal/operators/switchMap.js.SwitchMapOperator.call @ switchMap.js:19
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:24
subscribeToResult @ subscribeToResult.js:13
push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._innerSub @ mergeMap.js:74
push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._tryNext @ mergeMap.js:68
push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._next @ mergeMap.js:51
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:53
(anonymous) @ subscribeToArray.js:5
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe @ Observable.js:43
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:29
push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapOperator.call @ mergeMap.js:29
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:24
push../node_modules/rxjs/_esm5/internal/operators/filter.js.FilterOperator.call @ filter.js:15
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:24
push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapOperator.call @ mergeMap.js:29
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:24
push../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchOperator.call @ catchError.js:18
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:24
push../src/app/shared/layout/notifications/header-notifications.component.ts.HeaderNotificationsComponent.loadNotifications @ header-notifications.component.ts:37
push../src/app/shared/layout/notifications/header-notifications.component.ts.HeaderNotificationsComponent.ngOnInit @ header-notifications.component.ts:28
checkAndUpdateDirectiveInline @ core.js:21096
checkAndUpdateNodeInline @ core.js:29494
checkAndUpdateNode @ core.js:29456
debugCheckAndUpdateNode @ core.js:30090
debugCheckDirectivesFn @ core.js:30050
eval @ TopBarComponent.html:57
debugUpdateDirectives @ core.js:30042
checkAndUpdateView @ core.js:29438
callViewAction @ core.js:29679
execComponentViewsAction @ core.js:29621
checkAndUpdateView @ core.js:29444
callViewAction @ core.js:29679
execComponentViewsAction @ core.js:29621
checkAndUpdateView @ core.js:29444
callViewAction @ core.js:29679
execEmbeddedViewsAction @ core.js:29642
checkAndUpdateView @ core.js:29439
callViewAction @ core.js:29679
execComponentViewsAction @ core.js:29621
checkAndUpdateView @ core.js:29444
callViewAction @ core.js:29679
execEmbeddedViewsAction @ core.js:29642
checkAndUpdateView @ core.js:29439
callViewAction @ core.js:29679
execComponentViewsAction @ core.js:29621
checkAndUpdateView @ core.js:29444
callWithDebugContext @ core.js:30308
debugCheckAndUpdateView @ core.js:30010
push../node_modules/@angular/core/fesm5/core.js.ViewRef_.detectChanges @ core.js:20685
push../node_modules/@angular/core/fesm5/core.js.ApplicationRef.tick @ core.js:27108
(anonymous) @ core.js:26997
ZoneDelegate.invoke @ zone.js:396
onInvoke @ core.js:26255
ZoneDelegate.invoke @ zone.js:395
Zone.run @ zone.js:153
push../node_modules/@angular/core/fesm5/core.js.NgZone.run @ core.js:26169
next @ core.js:26997
schedulerFn @ core.js:23734
push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub @ Subscriber.js:192
push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next @ Subscriber.js:130
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next @ Subscriber.js:76
push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:53
push../node_modules/rxjs/_esm5/internal/Subject.js.Subject.next @ Subject.js:47
push../node_modules/@angular/core/fesm5/core.js.EventEmitter.emit @ core.js:23718
checkStable @ core.js:26224
onHasTask @ core.js:26268
ZoneDelegate.hasTask @ zone.js:451
ZoneDelegate._updateTaskCount @ zone.js:472
Zone._updateTaskCount @ zone.js:294
Zone.runTask @ zone.js:215
drainMicroTaskQueue @ zone.js:611
Promise.then (async)
scheduleMicroTask @ zone.js:594
ZoneDelegate.scheduleTask @ zone.js:420
onScheduleTask @ zone.js:304
ZoneDelegate.scheduleTask @ zone.js:410
Zone.scheduleTask @ zone.js:241
Zone.scheduleMicroTask @ zone.js:261
scheduleResolveOrReject @ zone.js:884
resolvePromise @ zone.js:830
(anonymous) @ zone.js:750
webpackJsonpCallback @ bootstrap:25
(anonymous) @ app-admin-admin-module.js:1
Show 109 more frames

5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Could you add a console.log as shown below into abp.js and share it's output ?

    abp.notifications.getFormattedMessageFromUserNotification = function (userNotification) {
    	console.log(userNotification.notification);
    	var formatter = abp.notifications.messageFormatters[userNotification.notification.data.type];
    	if (!formatter) {
    		abp.log.warn('No message formatter defined for given data type: ' + userNotification.notification.data.type)
    		return '?';
    	}
    
    	if (!abp.utils.isFunction(formatter)) {
    		abp.log.warn('Message formatter should be a function! It is invalid for data type: ' + userNotification.notification.data.type)
    		return '?';
    	}
    
    	return formatter(userNotification);
    }
    
  • User Avatar
    0
    TimMackey created

    This is my abp.js:

    var abp = abp || {};
    (function () {
    
        /* Application paths *****************************************/
    
        //Current application root path (including virtual directory if exists).	
        abp.appPath = abp.appPath || '/';
    
        /* UTILS ***************************************************/
    
        abp.utils = abp.utils || {};
    
        /**	
            * Sets a cookie value for given key.	
            * This is a simple implementation created to be used by ABP.	
            * Please use a complete cookie library if you need.	
            * @param {string} key	
            * @param {string} value	
            * @param {Date} expireDate (optional). If not specified the cookie will expire at the end of session.	
            * @param {string} path (optional)	
            */
        abp.utils.setCookieValue = function (key, value, expireDate, path) {
            var cookieValue = encodeURIComponent(key) + '=';
    
            if (value) {
                cookieValue = cookieValue + encodeURIComponent(value);
            }
    
            if (expireDate) {
                cookieValue = cookieValue + "; expires=" + expireDate.toUTCString();
            }
    
            if (path) {
                cookieValue = cookieValue + "; path=" + path;
            }
    
            document.cookie = cookieValue;
        };
    
        /**	
        * Gets a cookie with given key.	
        * This is a simple implementation created to be used by ABP.	
        * Please use a complete cookie library if you need.	
        * @param {string} key	
        * @returns {string} Cookie value or null	
        */
        abp.utils.getCookieValue = function (key) {
            var equalities = document.cookie.split('; ');
            for (var i = 0; i < equalities.length; i++) {
                if (!equalities[i]) {
                    continue;
                }
    
                var splitted = equalities[i].split('=');
                if (splitted.length != 2) {
                    continue;
                }
    
                if (decodeURIComponent(splitted[0]) === key) {
                    return decodeURIComponent(splitted[1] || '');
                }
            }
    
            return null;
        };
    
        /**	
        * Deletes cookie for given key.	
        * This is a simple implementation created to be used by ABP.	
        * Please use a complete cookie library if you need.	
        * @param {string} key	
        * @param {string} path (optional)	
        */
        abp.utils.deleteCookie = function (key, path) {
            var cookieValue = encodeURIComponent(key) + '=';
    
            cookieValue = cookieValue + "; expires=" + (new Date(new Date().getTime() - 86400000)).toUTCString();
    
            if (path) {
                cookieValue = cookieValue + "; path=" + path;
            }
    
            document.cookie = cookieValue;
        }
    
        /* SECURITY ***************************************/
        abp.security = abp.security || {};
        abp.security.antiForgery = abp.security.antiForgery || {};
    
        abp.security.antiForgery.tokenCookieName = 'XSRF-TOKEN';
        abp.security.antiForgery.tokenHeaderName = 'X-XSRF-TOKEN';
    
        abp.security.antiForgery.getToken = function () {
            return abp.utils.getCookieValue(abp.security.antiForgery.tokenCookieName);
        };
    
    })();
    

    Also, when opening this file the first time in Visual Studio 2019, this message appeared: I clicked 'No'.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    The message is irrelevant to this problem I guess. Could you check this file on your project https://github.com/aspnetzero/aspnet-zero-core/blob/dev/angular/src/assets/abp-web-resources/abp.js#L310 ?

    It should be located under angular/src/assets/abp-web-resources folder.

  • User Avatar
    0
    TimMackey created

    Added console.log to the file indicated. (Erroneously selected abp.js in aspnet-core Web.Host previously)

        abp.notifications.getFormattedMessageFromUserNotification = function (userNotification) {
            console.log(userNotification.notification);
            var formatter = abp.notifications.messageFormatters[userNotification.notification.data.type];
            if (!formatter) {
                abp.log.warn('No message formatter defined for given data type: ' + userNotification.notification.data.type)
                return '?';
            }
    
            if (!abp.utils.isFunction(formatter)) {
                abp.log.warn('Message formatter should be a function! It is invalid for data type: ' + userNotification.notification.data.type)
                return '?';
            }
    
            return formatter(userNotification);
        }
    

    This is the result of logging in as host admin.

    NODE_ENV: development
    Angular is running in the development mode. Call enableProdMode() to enable the production mode.
    [WDS] Live Reloading enabled.
    DEBUG:
    Starting connection using WebSockets transport
    DEBUG:
    Starting connection using WebSockets transport
    [2022-03-16T20:51:46.912Z] Information: WebSocket connected to wss://localhost:44301/signalr-chat?enc_auth_token=wNYmO41%2F48SHNstaLVXxHCCre29BZQl1NhC6NM3R3rzpXtPQxVzH6jEzA%2FQhXFN5tu6Fk7pO53uppm1mVXMZgxbyRVz26dnepi%2FFyB6axBY%2B6gq1GL%2BuRQgoiFUCjRN2p8w6LevViwKlHyWZZJZO1DGVSjAi1m2U%2Bog9pkHw9%2FQR4Nl%2FDPnoP9JYDMpZ1zxx09u6s0GZ9%2FQ5Sjk%2BL0UfcSCbl38X8he5w9UIn%2FHvxh7ysM1CiPLsoOwtbiieSRVmrmt0JjnipAn4%2FK283F8GrGwzwgehWsqefmUnM0ckMwP9ZAdwQxWDhxv0IqNw4tDhwUYs%2F1SYdYozdNzgByhgNOBPzQDObNLlWc4vV5VMOiZDJjcsnIYykTiXSD4eimMvZhR62FdwVXo34WRc2JPeF90Bk%2Bg1Oyra4MJGiSYGgGM%2BVz9H3Jmz1V0ChX9%2FJUWgMx2LaPHZOvMbCtwzSSMF%2B7f3avQlC5HvFhkBjBsZy3usjA5DLXFPpmqHcgaxU9y8nWX0a6hkw5oJ%2FgDw4hJnmjudgEBLa31I2BsBvnmxgO%2FWZEPWIPIHH3CfJ6fA9e3r0w61AARIQ9eal4nyBTeddudWIRsBO2lnuh67sXbPuTp%2B%2B1BXKCKPIxYRR5VgnPifyWeVyku1rM%2BMR14TbxKpqO2rD1bixPue0EmONlrRPoeiSs%2FhBLSTo3QV99l08GVICae%2BXuGlq%2FePTCtHqDTaa79jWfOd%2FwzJ0fZsOowt7i%2B1w344DfP9kFr5BsAyQ2dlGJ0VBvcFTxRCBfnAkSLDjij8hBYtm8GnHHU4O8nFLEdYfmjRdO23zH0Y63YYKsIyOWVSENmnvWUu4Ngzoh78UeUxZ8IWMmvD3FNQ2Cpkn9cWNpgrFzKg6dzu4ti9pXlgmwVV1kJBjXPSd4W%2FjH0ncvSFJMrhbFofohNvAAisK8az31GJmDCWSnPZfRuXZeL3Fzi5kVr376seCo4XEToLSKwypZcp1abnF3glb4S2TUPJBAsDoHkPLhySbbUt0jOlJyJTFEnYLkx%2BheDQRPBZug%3D%3D&id=IG8mQmTwe0pV4wA0ABGQAw.
    TenantNotification {tenantId: null, notificationName: 'App.NewTenantRegistered', data: undefined, entityType: null, entityTypeName: null, …}
    creationTime: Moment {_isAMomentObject: true, _i: '2022-03-08T09:32:37.7338681', _f: 'YYYY-MM-DDTHH:mm:ss.SSSS', _isUTC: false, _pf: {…}, …}
    data: undefined
    entityId: null
    entityType: null
    entityTypeName: null
    id: 'e3fdb00f-e90d-47ed-a400-1dcb454872af'
    notificationName: 'App.NewTenantRegistered'
    severity: 0
    tenantId: null
    [[Prototype]]: Object
    ERROR TypeError: Cannot read properties of undefined (reading 'type')
        at Object.abp.notifications.getFormattedMessageFromUserNotification (c:\Users\Tim\Documents\__ngTTMv831\ngTTM\angular\src\assets\abp-web-resources\abp.js:312:1)
        at UserNotificationHelper.push../src/app/shared/layout/notifications/UserNotificationHelper.ts.UserNotificationHelper.format (c:\Users\Tim\Documents\__ngTTMv831\ngTTM\angular\src\app\shared\layout\notifications\UserNotificationHelper.ts:69:45)
        at c:\Users\Tim\Documents\__ngTTMv831\ngTTM\angular\src\app\shared\layout\notifications\header-notifications.component.ts:41:70
        at arrayEach (c:\Users\Tim\Documents\__ngTTMv831\ngTTM\angular\node_modules\lodash\lodash.js:530:1)
        at Function.forEach (c:\Users\Tim\Documents\__ngTTMv831\ngTTM\angular\node_modules\lodash\lodash.js:9410:1)
        at SafeSubscriber._next (c:\Users\Tim\Documents\__ngTTMv831\ngTTM\angular\src\app\shared\layout\notifications\header-notifications.component.ts:40:22)
        at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (c:\Users\Tim\Documents\__ngTTMv831\ngTTM\angular\node_modules\rxjs\_esm5\internal\Subscriber.js:192:1)
        at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (c:\Users\Tim\Documents\__ngTTMv831\ngTTM\angular\node_modules\rxjs\_esm5\internal\Subscriber.js:130:1)
        at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (c:\Users\Tim\Documents\__ngTTMv831\ngTTM\angular\node_modules\rxjs\_esm5\internal\Subscriber.js:76:1)
        at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (http://localhost:4200/vendor.js:225595:18) {stack: 'TypeError: Cannot read properties of undefine…t (http://localhost:4200/vendor.js:225595:18)', message: 'Cannot read properties of undefined (reading 'type')'}
    [2022-03-16T20:51:50.916Z] Information: WebSocket connected to wss://localhost:44301/signalr?enc_auth_token=wNYmO41%2F48SHNstaLVXxHCCre29BZQl1NhC6NM3R3rzpXtPQxVzH6jEzA%2FQhXFN5tu6Fk7pO53uppm1mVXMZgxbyRVz26dnepi%2FFyB6axBY%2B6gq1GL%2BuRQgoiFUCjRN2p8w6LevViwKlHyWZZJZO1DGVSjAi1m2U%2Bog9pkHw9%2FQR4Nl%2FDPnoP9JYDMpZ1zxx09u6s0GZ9%2FQ5Sjk%2BL0UfcSCbl38X8he5w9UIn%2FHvxh7ysM1CiPLsoOwtbiieSRVmrmt0JjnipAn4%2FK283F8GrGwzwgehWsqefmUnM0ckMwP9ZAdwQxWDhxv0IqNw4tDhwUYs%2F1SYdYozdNzgByhgNOBPzQDObNLlWc4vV5VMOiZDJjcsnIYykTiXSD4eimMvZhR62FdwVXo34WRc2JPeF90Bk%2Bg1Oyra4MJGiSYGgGM%2BVz9H3Jmz1V0ChX9%2FJUWgMx2LaPHZOvMbCtwzSSMF%2B7f3avQlC5HvFhkBjBsZy3usjA5DLXFPpmqHcgaxU9y8nWX0a6hkw5oJ%2FgDw4hJnmjudgEBLa31I2BsBvnmxgO%2FWZEPWIPIHH3CfJ6fA9e3r0w61AARIQ9eal4nyBTeddudWIRsBO2lnuh67sXbPuTp%2B%2B1BXKCKPIxYRR5VgnPifyWeVyku1rM%2BMR14TbxKpqO2rD1bixPue0EmONlrRPoeiSs%2FhBLSTo3QV99l08GVICae%2BXuGlq%2FePTCtHqDTaa79jWfOd%2FwzJ0fZsOowt7i%2B1w344DfP9kFr5BsAyQ2dlGJ0VBvcFTxRCBfnAkSLDjij8hBYtm8GnHHU4O8nFLEdYfmjRdO23zH0Y63YYKsIyOWVSENmnvWUu4Ngzoh78UeUxZ8IWMmvD3FNQ2Cpkn9cWNpgrFzKg6dzu4ti9pXlgmwVV1kJBjXPSd4W%2FjH0ncvSFJMrhbFofohNvAAisK8az31GJmDCWSnPZfRuXZeL3Fzi5kVr376seCo4XEToLSKwypZcp1abnF3glb4S2TUPJBAsDoHkPLhySbbUt0jOlJyJTFEnYLkx%2BheDQRPBZug%3D%3D&id=gS1d-acwwPoW-09TkvuAPg.
    DEBUG:
    Connected to SignalR server!
    DEBUG:
    Registered to the SignalR server!
    

    The problem seems to be userNotification.notification.data is undefined.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I have created an issue, please follow https://github.com/aspnetzero/aspnet-zero-core/issues/4301.

    As a workaround, you can change getFormattedMessageFromUserNotification as shown below;

    abp.notifications.getFormattedMessageFromUserNotification = function (userNotification) {
    	if(!userNotification.notification.data){
    		return '?';
    	}
    	
    	var formatter = abp.notifications.messageFormatters[userNotification.notification.data.type];
    	if (!formatter) {
    		abp.log.warn('No message formatter defined for given data type: ' + userNotification.notification.data.type)
    		return '?';
    	}
    
    	if (!abp.utils.isFunction(formatter)) {
    		abp.log.warn('Message formatter should be a function! It is invalid for data type: ' + userNotification.notification.data.type)
    		return '?';
    	}
    
    	return formatter(userNotification);
    }