0

Sometimes my customer's iPad; iPadOS 14.5 catches 'Unexpected token '<''. Logged in? even if it's operating without problems a few minutes ago. The message confuses me and I want to know where is the problems. They use Native Salesforce app, and call our apps from it.

I make React/Redux on a StaticResources, VF page calls those scripts and it calls Apex class. When reload part of screen, JS catches error "'Unexpected token '<''. Logged in?"

Other pages are displayed without any problem, like Account Page.

I watched an article below, my code doesn't use URLRewriter.

Visualforce Remoting Exception: Error parsing json response: 'Unexpected token <'. Logged in?

here's JS code:

    callApi(_serviceName, _methodName, _params, _callback) {
        let req = {
            service: _serviceName,
            method: _methodName,
            params: JSON.stringify(_params, replacer),
        };

        let callback = (_callback && (typeof _callback == 'function')) ? _callback : null;

        const remotingOptions = {
            buffer: false,
            timeout: 120000,
        };

        return new Promise((resolve, reject) => {

            Env.remotingObj.invoke(req, function (response, event) {

                try {
                    if (event.status && response.status === 0) {
                        // When it's success
                        let result = TextUtil.unescape(response.result);

                        if (callback) {
                            callback(true, result);
                        }

                        return resolve(result);

                    } else {
                        let message = event.status ? (response || {}).error : event.message;

                        // here's Unexpected token '<'. Logged in?
                        if (message.indexOf('Logged in') > 0) {
                            message = Lang.get('XXXX_MSG_SESSION_TIMEOUT');
                        }
                        if (callback) {
                            callback(false, message);
                        }
                        return reject(new Error(message));
                    }

                } catch (e) {
                    return reject(e);
                }
            }, remotingOptions);
}

and here's Apex code:

public with sharing class Srv_Place implements Inv_IF {

    public Map<String, Object> execute(String methodName, string params) {
        Map<String, Object> paramMap = (Map<String, Object>)JSON.deserializeUntyped(params);

        if (methodName == 'select') {
            return executeSelect(paramMap);

        } else {
            throw Inv_Exception.createBadMethod(methodName);
        }
....
    }
2
  • 1
    That happens to VF remoting if session is expired. I have seen same one on desktop if i click log out in another window
    – kurunve
    Mar 16, 2021 at 9:40
  • Thank you @kurunve and yes, I've seen in your case. I wonder why it's expired on Salesforce App. They say they aren't use Safari or Chrome between app operations. And no other organization are fine, session isn't expired.
    – Asae
    Mar 17, 2021 at 1:20

0

You must log in to answer this question.

Browse other questions tagged .