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

[Bug]: Login: Error while identifying/upserting user: identifyUser: malformed request: Subscription not found #1185

Open
vladbalmos opened this issue Jul 18, 2024 · 2 comments

Comments

@vladbalmos
Copy link

What happened?

This error appears intermittently while trying to log the user in and add data tags after client subscribes. The user is not logged in and no tags are added, a page refresh is necessary to complete the procedure

Full error message:

LoginManager.js:80 Login: Error while identifying/upserting user: identifyUser: malformed request: {"errors":[{"code":"subscription-0","title":"Subscription not found","meta":{"alias":{"Label":"onesignal_id","ID":"[onesignalid]"}}}]}

The ids in the log have been changed for privacy reasons

What browsers are you seeing the problem on?

Chrome (Chromium)

What operating system are you running?

MacOS, Linux, Windows

Steps to reproduce?

My code:


$(async () => {
    const tags = {"tag": "value"};
    OneSignalDeferred.push(async function (OneSignal) {
        await OneSignal.init({
            appId: "[APP ID]",
            notifyButton: {
                enable: true
            },
            serviceWorkerParam: { scope: "/js/sw/" },
            serviceWorkerPath: "/js/sw/onesignalsdkworker.js"
        });

        if (OneSignal.User.onesignalId &&
            OneSignal.User.PushSubscription.id &&
            OneSignal.User.PushSubscription.id &&
            OneSignal.User.PushSubscription.token &&
            OneSignal.User.PushSubscription.optedIn
        ) {
            OneSignal.User.addTags(tags);
            return;
        }

        OneSignal.User.PushSubscription.addEventListener('change', async (event) => {
            if (!event.current.token) {
                return;
            }
            setTimeout(async () => {
                await OneSignal.login(id_user);
                OneSignal.User.addTags(tags);
            }, 2000); // without the timeout the error appears more often

        });
    });
})

I added a delay between the push subscription change event and the user login & add tags to try to minimize the error occurrences but I still get them from time to time.



### What did you expect to happen?

The user should have been logged in and the data tags should have been added right after confirming the push notification subscription

### Relevant log output

```Shell
LoginManager.js:80 Login: Error while identifying/upserting user: identifyUser: malformed request: {"errors":[{"code":"subscription-0","title":"Subscription not found","meta":{"alias":{"Label":"onesignal_id","ID":"58eea521-83da-4a6a-9428-d90aa2f51f81"}}}]}
(anonymous)	@	LoginManager.js:80
Promise.then (async)		
login	@	OneSignalSDK.page.es6.js?v=160201:1
(anonymous)	@	OneSignal.js:84
login	@	OneSignalSDK.page.es6.js?v=160201:1
(anonymous)	@	1721281600.min.js:1
setTimeout (async)		
(anonymous)	@	1721281600.min.js:1
(anonymous)	@	Emitter.js:113
Promise.then (async)		
emit	@	OneSignalSDK.page.es6.js?v=160201:1
(anonymous)	@	OneSignalEvent.js:49
trigger	@	OneSignalSDK.page.es6.js?v=160201:1
triggerSubscriptionChanged	@	EventHelper.js:155
(anonymous)	@	EventHelper.js:61
Promise.then (async)		
checkAndTriggerSubscriptionChanged	@	OneSignalSDK.page.es6.js?v=160201:1
(anonymous)	@	SubscriptionHelper.js:22
Promise.then (async)		
internalRegisterForPush	@	OneSignalSDK.page.es6.js?v=160201:1
(anonymous)	@	SubscriptionHelper.js:9
registerForPush	@	OneSignalSDK.page.es6.js?v=160201:1
(anonymous)	@	InitHelper.js:74
registerForPushNotifications	@	OneSignalSDK.page.es6.js?v=160201:1
(anonymous)	@	PromptsManager.js:114
internalShowNativePrompt	@	OneSignalSDK.page.es6.js?v=160201:1
(anonymous)	@	PromptsManager.js:86
Promise.then (async)		
internalShowDelayedPrompt	@	OneSignalSDK.page.es6.js?v=160201:1
(anonymous)	@	PromptsManager.js:46
spawnAutoPrompts	@	OneSignalSDK.page.es6.js?v=160201:1
(anonymous)	@	InitHelper.js:68
Promise.then (async)		
sessionInit	@	OneSignalSDK.page.es6.js?v=160201:1
(anonymous)	@	InitHelper.js:28
Promise.then (async)		
internalInit	@	OneSignalSDK.page.es6.js?v=160201:1
(anonymous)	@	OneSignal.js:141
Promise.then (async)		
e	@	OneSignalSDK.page.es6.js?v=160201:1
(anonymous)	@	OneSignal.js:145
_delayedInit	@	OneSignalSDK.page.es6.js?v=160201:1
(anonymous)	@	OneSignal.js:121
Show 93 more frames
OneSignalApiBase.js:53 Fetch failed loading: PATCH "https://onesignal.com/api/v1/apps/[appid]/users/by/onesignal_id/58eea521-83da-4a6a-9428-d90aa2f51f81/identity".
OneSignalApiBase.js:53 
 GET https://onesignal.com/api/v1/apps/[appid]/users/by/onesignal_id/58eea521-83da-4a6a-9428-d90aa2f51f81 404 (Not Found)
CoreModuleDirector.js:54 
Error hydrating user: TypeError: Cannot destructure property 'onesignal_id' of 'e.identity' as it is undefined.
LoginManager.js:95 n: identifyUser: malformed request: {"errors":[{"code":"subscription-0","title":"Subscription not found","meta":{"alias":{"Label":"onesignal_id","ID":"58eea521-83da-4a6a-9428-d90aa2f51f81"}}}]}
    at tn.<anonymous> (https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.es6.js?v=160201:1:219583)
    at Generator.next (<anonymous>)
    at r (https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.es6.js?v=160201:1:262795)
OneSignalApiBase.js:53 Fetch failed loading: GET "https://onesignal.com/api/v1/apps/[appid]/users/by/onesignal_id/58eea521-83da-4a6a-9428-d90aa2f51f81".
OneSignalApiBase.js:53 
 PATCH https://onesignal.com/api/v1/apps/[appid]/subscriptions/a0219da9-b180-47a4-8066-2e4f8b2b6e43 404 (Not Found)
OneSignalApiBase.js:53 Fetch failed loading: PATCH "https://onesignal.com/api/v1/apps/[appid]/subscriptions/a0219da9-b180-47a4-8066-2e4f8b2b6e43".
SessionManager.js:179 Error handling blur: n: Abort _getOneSignalAndSubscriptionIds: no identity
    at Kt.<anonymous> (https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.es6.js?v=160201:1:106896)
    at Generator.next (<anonymous>)
    at r (https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.es6.js?v=160201:1:262795)
OneSignalApiBase.js:53 Fetch finished loading: PATCH "https://onesignal.com/api/v1/apps/[appid]/users/by/onesignal_id/c1bcce3b-b5bc-4481-b337-87e6d9b641a1".
@Ratatinator97
Copy link

Is there any news on that issue ?

@vladbalmos
Copy link
Author

Is this SDK still maintained?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants