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

Error: JSON Parse error: Unexpected token: < #55

Open
yachtwave opened this issue May 10, 2023 · 18 comments · May be fixed by #60
Open

Error: JSON Parse error: Unexpected token: < #55

yachtwave opened this issue May 10, 2023 · 18 comments · May be fixed by #60

Comments

@yachtwave
Copy link

yachtwave commented May 10, 2023

I am intermittently seeing an exception when calling "checkVersion". The exception happens about 25% of the time. im calling the function as follows:

    let check = await checkVersion({
        version: versionLocal, // app local version
        iosStoreURL: updateConfig.urls.ios.check,
        androidStoreURL: updateConfig.urls.android.check,
        country: 'us',
    });

where variables are (expect i am using my real id# and app name) :

    ios: {
        check: 'https://apps.apple.com/us/app/yachtwave/id1234567890',
    },
    android: {
        check: 'https://play.google.com/store/apps/details?id=com.myapp.app',

Hoping you can help find the issue as it is affecting version checks - thanks!

@KiranRadish
Copy link

KiranRadish commented May 12, 2023

i am also having same issue
[Error: JSON Parse error: Unrecognized token '<']
@jeokeefe did you found solution for this?

@yachtwave
Copy link
Author

@KiranRadish I have not found a solution, we pushed our latest update with it like that. We catch the exception and then just move on...

@McFlyssss
Copy link

We are having the same issues here. As @jeokeefe pointed out, it does not happen every time.

@watanabeyu
Copy link
Owner

Hi everyone.

Sorry to reply.
I will fix this, so please wait.
I can probably fix this in 2 days.

thanks

@watanabeyu
Copy link
Owner

watanabeyu commented May 25, 2023

@jeokeefe @McFlyssss @KiranRadish
I think it's because the version is no longer listed on the play store.
Please yours play store url.
I found there may be certain rules.

Pattern A

This app using my library.
Press the button [About this app ->] and see if the version notation part in the displayed modal looks like this.
Group 15

Pattern B

This app I created, and version is displayed.
スクリーンショット 2023-05-25 15 58 02

What?

So, I want to check different.
My app build type is .aab.
Which type aab or apk your apps.

Maybe it's different depending on whether it's aab or apk.
or maybe something else...

First of all, please tell me if it's aab or apk.

thanks

@McFlyssss
Copy link

Hi @watanabeyu ,

Thanks for taking a look into this. We actually are having those issues on the iOS side of the things. Android is working just fine for us.

@watanabeyu
Copy link
Owner

Umm...please your app store url

@McFlyssss
Copy link

Sure thing! There you go: https://apps.apple.com/app/nuvolops-crew-app/id1536764075

@yachtwave
Copy link
Author

yachtwave commented May 25, 2023 via email

@watanabeyu
Copy link
Owner

@McFlyssss
Thanks url.
I can get version.
Enter the appstore url in the url below and try it
https://snack.expo.dev/@watanabe_yu/react-native-store-version-example?platform=ios

スクリーンショット 2023-05-25 21 21 03

@watanabeyu
Copy link
Owner

@jeokeefe
Thanks url.
I can get version.
Enter the appstore url in the url below and try it.

I think it's probably because I didn't put in the country.
Is it because the default countryCode is jp?
https://snack.expo.dev/@watanabe_yu/react-native-store-version-example?platform=ios

スクリーンショット 2023-05-25 21 24 29

@yachtwave
Copy link
Author

yachtwave commented May 25, 2023 via email

@yachtwave
Copy link
Author

yachtwave commented May 25, 2023 via email

@McFlyssss
Copy link

Hi again @watanabeyu

Thanks again for checking this out. As you can see on my screenshot I got to reproduce the error:
Screenshot 2023-05-25 at 16 45 04

@watanabeyu
Copy link
Owner

@jeokeefe

I’m using “us” and the issue only happens about 20% of the time, all others it works. It is odd.

Hmm, I've never encountered that phenomenon.
I don't think it's a problem if you can get it even once, but maybe the iOS lookup API is sometimes strange.
For the time being, I feel that this library does not seem to be...
Let me know once again if you find something like that.

@watanabeyu
Copy link
Owner

@McFlyssss

const check = await checkVersion({
  version,
  iosStoreURL: 'https://apps.apple.com/app/nuvolops-crew-app/id1536764075',
  country:"us",
});

Could you try putting in the countryCode like this?

@yachtwave
Copy link
Author

i just made the change to "us" (double quotes) ill run for a bit and provide an update.

@miso-belica
Copy link

Hello, I see this error in Sentry for our app many times. It's only iOS and the solution seems to be this #46. The problem is the API call sometimes ends with the error below and HTML is probably returned instead of JSON.

GET https://itunes.apple.com/lookup
{
  http.status: 503
  http.query: id=1234567890&country=us&1727644468925,
  reason: service unavailable,
}

Also, I see no matter what HTTP header is sent API always returns response as Content-Type: text/javascript; charset=utf-8 so it's basically Javascript object but written the way it is compatible with JSON.

@miso-belica miso-belica linked a pull request Sep 30, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

5 participants